import {selectDialogMixins} from "@base/mixins/selectDialog";
import {getJsxStatus} from "@base/views/bd/setting/utils/index";

let modules = {};
modules = {
  props: ['visiable', 'multi', 'rows', 'param'],
  mixins: [selectDialogMixins],
  created() {
    this.initSetting();
  },
  mounted() {
    this.initTableM1();
  },
  data() {
    var that = this;
    return {
      showDialog: true,
      falseValue: false,
      selectMulti: true,
      formData: {},
      vxeOption: {}
    };
  },
  methods: {
    initTableM1() {
      let that = this;
      let tableOption = {
        vue: this,
        tableRef: 'table-m1',
        tableName: 'user_form_template_dialog-m1',
        path: USER_PREFIX + '/formTemplate/listPage',
        param: () => {
          return {
            ...this.formData,
            enabled: true,
            history: false
          };
        },
        config: {
          checkboxConfig: {
            checkStrictly: true,
            showHeader: this.selectMulti,
            trigger: 'row'
          }
        },
        columns: [
          {type: 'checkbox', width: 48, resizable: false, fixed: 'left'},
          {
            title: this.$t1('模板名称'),
            field: 'formName',
            width: 150,
            fixed: 'left'
          },
          {
            title: this.$t1('模板编码'),
            field: 'formCode',
            width: 150
          },
          {
            title: this.$t1('模板版本'),
            field: 'formVersion',
            width: 150
          },
          {
            title: this.$t1('是否启用'),
            field: 'enabled',
            width: 150,
            slots: {
              default: ({row}) => {
                if (row.enabled) {
                  return getJsxStatus(null,this.$t1('启用'))
                } else {
                  return getJsxStatus('s-3',this.$t1('禁用'))
                }
              }
            }
          },
          {
            title: this.$t1('备注'),
            field: 'remark',
            width: 150
          },
          {
            title: this.$t1('数据表名'),
            field: 'ftableName',
            width: 200
          },
          {field: 'serviceName', title: this.$t1('服务名'), width: 150},
          {
            title: this.$t1('创建时间'),
            field: 'createDate',
            width: 150
          },
          {
            width: 47,
            fixed: 'right',
            title: '',
            sortable: false,
          }
        ]
      };
      this.$vxeTableUtil.initVxeTable(tableOption).then(opts => {
        this.vxeOption = opts;
      });
    }
  }
};
export default modules
