let modules = {};
 
modules = {
  props: ['visiable', 'multi', 'rows', 'param', 'current_prefix', 'wfInfo'],
  data() {
    return {
      vxeOption: {},
      script:null,
      showDialog: true,
      currentRow:null,
      showScriptDialog:false,
      scriptTypeMap:{
        'pre': '前置事件',
        'post': '后置事件',
        'candidate': '候选人事件',
        'start': '开始事件',
        'end': '结束事件',
        'interrupt': '中断事件',
        'conditions': '条件事件',
        'countersignSubmit': '会签提交事件'
      },
      scritpDialogTitle: null


    }
  },
  mounted() {
    this.initTableM1()
  },
  methods: {
    searchEvent() {
      this.$refs['table-m1'].commitProxy('reload');
    },
    closeDialog(){
      this.$emit("update:visiable", false);
    },
    initTableM1() {
      let that = this;
      let scriptTypeMap = this.scriptTypeMap
      let tableOption = {
        vue: that,
        tableRef: 'table-m1',
        tableName: 'setCandidateDialog_dialog-m1',
        path: this.current_prefix + '/wf_flow_ele_script/list',
        param: () => {
          return {
            modelId: this.wfInfo.modelId,
            procDefId: this.wfInfo.procDefId,
          }
        },
        config: {
          /*checkboxConfig: {
            checkStrictly: true,
            showHeader: this.selectMulti,
          },*/
          pagerConfig:{
            autoHidden: true
          },
          proxyConfig: {
            props: {
              result: "objx", // 配置响应结果列表字段
              total: "objx.length", // 配置响应结果总页数字段
            },
          },
        },
        columns: [
          {type: 'checkbox', width: 50, resizable: false, fixed: 'left'},
          {title: this.$t2('节点名称', 'components.wf.nodeName'), field: 'eleName', width: 250, fixed: 'left'},
          {
            field: 'scriptType',
            title: this.$t1('脚本类型'),
            width: 150,
            slots: {
              default: ({row})=>{
                return scriptTypeMap[row.scriptType]
              }
            }
          },
          {title: this.$t1('更新时间'), field: 'modifyDate', width: 150},
          {
            width: 150,
            fixed: 'right',
            title: '',
            sortable: false,
            slots: {
              default: 'operate'
            }
          }
        ]
      };
      this.$vxeTableUtil.initVxeTable(tableOption).then(opts => {
        that.vxeOption = opts;
      });
    },
    openScriptDialog(row){
      let scriptTypeMap = this.scriptTypeMap
      this.scritpDialogTitle = row.eleName + "(" + scriptTypeMap[row.scriptType] + ")"
      this.script = row.script
      this.currentRow = row
      this.showScriptDialog = true
    },
    saveScript() {
      this.$baseConfirm(this.$t1('您确定要保存脚本吗？')).then(() => {
        var url = this.current_prefix + '/wf_flow_ele_script/updateScript';
        this.$http({
          url: url,
          method: `post`,
          data: {
            ...this.currentRow,
            script: this.script
          },
          isLoading: true,
          success: res => {
            this.$message({
              message: res.content,
              type: 'success'
            });
            this.showScriptDialog = false;
            this.searchEvent();
          }
        });
      });

    },
    
  }


};

export default modules
