<template>
  <div>
    <base-page
      :searchParams="searchParams"
      :tableParams="tableParams"
      :tableUrl="tableUrl"
      :addUrl="addUrl"
      :editUrl="editUrl"
      :delUrl="delUrl"
      :editAuth="editAuth"
      :delAuth="delAuth"
      :infoUrl="infoUrl"
      :exportUrl="exportUrl"
      :importUrl="importUrl"
      :mubanUrl="mubanUrl"
      :editParams="editParams"
      :editElseRules="editElseRules"
      :editBtnName="(item) => (!item.latitude ? '待完善' : '修改')"
      idName="icDangerousChemicalsId"
    ></base-page>
  </div>
</template>

<script>
import basePage from "@/views/modules/cpts/base/index";

export default {
  props: {},

  data() {
    return {
      searchParams: [
        { field: "活动标题", keyName: "name", type: "input" },
        {
          field: "分类",
          keyName: "category",
          type: "select",
          optionUrl: "/gov/org/coverage/dict-select-list/dangerous_chemicals",
          optionUrlParams: {},
          optionList: [],
        },
        {
          field: "状态",
          keyName: "status",
          type: "select",
          optionUrl: "",
          optionUrlParams: {},
          optionList: [
            {
              label: "全部",
              value: "0",
            },
            {
              label: "已发布",
              value: "1",
            },
            {
              label: "已下线",
              value: "2",
            },
          ],
        },
        {
          field: "发布范围",
          keyName: "dangerType",
          type: "select",
          optionUrl: "/sys/dict/data/dictlist",
          optionUrlParams: {
            dictType: "ic_danger_type",
          },
          optionList: [],
        },
        {
          field: "发布时间",
          keyName: "publishTime",
          type: "date-range",
          supKeys: ["startTime", "endTime"],
          supValues: ["", ""],
        },
      ],

      tableParams: [
        { field: "序号", keyName: "", type: "no" },
        { field: "企业名称", keyName: "name", type: "text" },
        { field: "企业类别", keyName: "categoryName", type: "text" },
        { field: "周边安全间距", keyName: "safeDistanceName", type: "text" },
        { field: "危化品种类", keyName: "dangerTypeName", type: "text" },
        { field: "经营地址", keyName: "address", type: "text" },
        { field: "负责人", keyName: "principalName", type: "text" },
        { field: "联系电话", keyName: "principalMobile", type: "text" },
        { field: "备注", keyName: "remark", type: "text" },
      ],
      tableUrl: "/gov/org/icDangerousChemicals/list",
      mubanUrl: "/gov/org/icDangerousChemicals/download",
      importUrl: "/gov/org/icDangerousChemicals/import",
      exportUrl: "/gov/org/icDangerousChemicals/export",

      addUrl: "/gov/org/icDangerousChemicals/add",
      editUrl: "/gov/org/icDangerousChemicals/edit",
      infoUrl: "/gov/org/icDangerousChemicals/detail",
      delUrl: "/gov/org/icDangerousChemicals/del",
      editAuth(item) {
        return item.agencyId == this.$store.state.user.agencyId;
      },
      delAuth(item) {
        return item.agencyId == this.$store.state.user.agencyId;
      },

      editParams: [
        {
          field: "企业名称",
          keyName: "name",
          type: "input",
          maxlength: 50,
          editDisabled: true,
          rules: [
            {
              required: true,
              message: "企业名称不能为空",
              trigger: "blur",
            },
          ],
        },
        {
          field: "企业分类",
          keyName: "category",
          type: "select",
          optionUrl: "/gov/org/coverage/dict-select-list/dangerous_chemicals",
          optionUrlParams: {
            // dictType: "ic_service_type",
          },
          optionList: [],
          editDisabled: true,
          rules: [
            { required: true, message: "企业分类不能为空", trigger: "blur" },
          ],
        },
        {
          field: "周边安全间距",
          keyName: "safeDistance",
          type: "number",
          precision: 2,
          step: 0.01,
          min: 0,
          max: 1000000000,
          unitName: "公里",
        },
        {
          field: "危化品种类",
          keyName: "dangerType",
          type: "select",
          optionUrl: "/sys/dict/data/dictlist",
          optionUrlParams: {
            dictType: "ic_danger_type",
          },
          optionList: [],
          editDisabled: true,
        },
        {
          field: "负责人",
          keyName: "principalName",
          type: "input",
          maxlength: 50,
        },
        {
          field: "联系电话",
          keyName: "principalMobile",
          type: "input",
          maxlength: 50,
        },
        {
          field: "经营地址",
          keyName: "address",
          type: "address",
          maxlength: 50,
          supKeys: ["longitude", "latitude"],
          supValues: ["", ""],
          rules: [
            {
              required: true,
              message: "经营地址坐标不能为空",
              trigger: "blur",
            },
          ],
        },
        { field: "备注", keyName: "remark", type: "textarea" },
      ],
      editElseRules: {
        longitude: {
          type: "number",
          required: true,
          message: "请拖动地图选择坐标点",
        },
      },
    };
  },
  components: { basePage },
  computed: {},
  watch: {},

  async mounted() {},

  methods: {},
};
</script>

<style lang="scss" scoped></style>
