import { selectDialogMixins } from "@base/mixins/selectDialog";

let modules = {};
modules = {
  name: "zdDialog",
  props: ["visiable", "multi", "rows", "param", "taBm"],
  mixins: [selectDialogMixins],
  components: {},
  created() {
    this.initSetting();
  },
  mounted() {
    this.initTableM1();
  },
  data() {
    return {
      showDialog: true,
      falseValue: false,
      selectMulti: true,
      formData: {},
      vxeOption: {},
      showSaleOrgDialog: false,
      fieldKey: "taZdMc",
    };
  },
  methods: {
    initTableM1() {
      let that = this;

      let zdTypeMap = {
        Boolean: this.$t1("布尔"),
        Integer: this.$t1("整数"),
        Long: this.$t1("长整数"),
        Decimal: this.$t1("精度小数"),
        Money: this.$t1("金额"),
        Text: this.$t1("文本"),
        TextArea: this.$t1("长文本"),
        DateTime: this.$t1("日期时间"),
        Reference: this.$t1("关联表(文本)"),
        ReferenceLong: this.$t1("关联表(长整型)"),
      };

      let tableOption = {
        vue: that,
        tableRef: "table-m1",
        tableName: "bd_table_model_field_dialog-m1",
        path: USER_PREFIX + "/szTaMb/getSzTaZdMbsByTaBm",
        param: () => {
          return {
            taBm: this.taBm,
            enabled: true,
            searchDb: true,
            ...this.formData,
            ...this.param,
          };
        },
        columns: [
          { type: "checkbox", width: 48, resizable: false, fixed: "left" },
          {
            title: this.$t1("实体字段名称"),
            field: "zdEn",
            width: 150,
          },
          {
            title: this.$t1("数据库表字段名"),
            field: "taZdMc",
            width: 150,
          },
          {
            title: this.$t1("字段描述"),
            field: "zdCh",
            width: 150,
          },
          {
            title: this.$t1("字段类型"),
            field: "zdType",
            width: 150,
            slots: {
              default: ({ row, rowIndex, $table }) => {
                return zdTypeMap[row.zdType];
              },
            },
          },
          {
            title: this.$t1("关联字段"),
            field: "referenceZd",
            width: 150,
          },
          {
            width: 47,
            fixed: "right",
            title: "",
            sortable: false,
          },
        ],
        config: {
          checkboxConfig: {
            checkStrictly: true,
            showHeader: this.selectMulti,
            trigger: "row",
          },
          proxyConfig: {
            props: {
              result: "objx", // 配置响应结果列表字段
              total: "objx.length", // 配置响应结果总页数字段
            },
          },
        },
      };
      this.$vxeTableUtil.initVxeTable(tableOption).then((opts) => {
        that.vxeOption = opts;
      });
    },
  },
};
export default modules;
