{"remainingRequest":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\thread-loader\\dist\\cjs.js!D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\babel-loader\\lib\\index.js!D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\cache-loader\\dist\\cjs.js??ref--0-0!D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\xq-web-bpm\\src\\components\\ImportExportData\\DataTemplateSetting.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\src\\components\\ImportExportData\\DataTemplateSetting.vue","mtime":1675071991085},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\thread-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["import \"regenerator-runtime/runtime\";\nimport _asyncToGenerator from \"D:/jenkins/workspace/xq-web-bpm/node_modules/@babel/runtime/helpers/esm/asyncToGenerator\";\nimport \"core-js/modules/es6.number.constructor\";\nimport \"core-js/modules/es6.string.iterator\";\nimport \"core-js/modules/es6.map\";\nimport \"core-js/modules/web.dom.iterable\";\nimport \"core-js/modules/es6.array.sort\";\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\nimport utils from '@/hotent-ui-util';\nimport portal from '@/api/portal';\nimport AddFields from '@/components/ImportExportData/AddFields';\nimport FormatJson from '@/components/ImportExportData/FormatJson';\nexport default {\n  name: 'DataTemplateSetting',\n  components: {\n    AddFields: AddFields,\n    FormatJson: FormatJson\n  },\n  props: {\n    // 页面组件别名\n    bizCode: {\n      type: String,\n      default: '',\n      required: true\n    },\n    // 模板文件名称\n    tempFiles: {\n      type: String,\n      default: '',\n      required: true\n    },\n    type: {\n      type: String,\n      default: 'import',\n      required: true,\n      validator: function validator(type) {\n        if (type == 'import' || 'export') {\n          return true;\n        } else {\n          return false;\n        }\n      }\n    },\n    originAPIOptions: {\n      type: Object,\n      default: function _default() {},\n      required: true\n    },\n    dataBaseOptions: {\n      type: Object,\n      default: function _default() {},\n      required: true\n    }\n  },\n  computed: {\n    title: function title() {\n      if (this.type == 'import') {\n        return '导入模板配置';\n      } else {\n        return '导出模板配置';\n      }\n    }\n  },\n  data: function data() {\n    return {\n      dialogShow: false,\n      tableHeight: 300,\n      tempId: '',\n      tempData: {},\n      // 模板基础数据\n      data: [],\n      loading: false\n    };\n  },\n  mounted: function mounted() {\n    var _this = this;\n\n    this.calcTableHeight();\n    this.$root.$on('resize', function () {\n      _this.calcTableHeight(500);\n    });\n  },\n  methods: {\n    changeViewType: function changeViewType(index, row) {\n      var tempRow = utils.deepClone(row);\n      tempRow.fieldDataJson = '';\n      this.data.splice(index, 1, tempRow);\n    },\n    checkNumber: function checkNumber(index, row, num) {\n      var number;\n\n      if (!num) {\n        number = 0;\n      } else {\n        number = parseInt(num);\n\n        if (number < 0) {\n          number = 0;\n        }\n      }\n\n      row.orderIndex = number;\n      this.data.splice(index, 1, row);\n    },\n    sortData: function sortData() {\n      this.data.sort(function (a, b) {\n        var nameA = a.orderIndex;\n        var nameB = b.orderIndex;\n\n        if (nameA < nameB) {\n          return -1;\n        }\n\n        if (nameA > nameB) {\n          return 1;\n        }\n\n        return 0;\n      });\n    },\n    kvJson: function kvJson(json) {\n      var kvJson = {};\n\n      if (json) {\n        var temp = JSON.parse(json);\n        temp.forEach(function (item) {\n          kvJson[item.value] = item.label;\n        });\n        kvJson = JSON.stringify(kvJson);\n      }\n\n      return kvJson;\n    },\n    // 保存配置\n    handleSave: function handleSave() {\n      var _this2 = this;\n\n      if (!this.data.length) {\n        this.$message.warning('请配置模板！');\n        return;\n      }\n\n      var dataParams = utils.deepClone(this.data);\n      dataParams.forEach(function (item, index) {\n        if (_this2.tempId) {\n          item.tempId = _this2.tempId;\n        }\n\n        item.type = _this2.type == 'import' ? 2 : 1;\n        item.fieldType = 1;\n        delete item.dataType;\n        delete item.fieldDesc;\n        delete item.key;\n        delete item.tableName;\n        delete item.columnComment;\n        delete item.columnName;\n      });\n      var data = {\n        excelTemp: {\n          id: this.tempData.id,\n          tempFiles: this.tempFiles,\n          bizCode: this.bizCode,\n          dbDataBase: this.dataBaseOptions.tableSchema,\n          dbSourceId: this.dataBaseOptions.dataBaseId,\n          dbTable: this.dataBaseOptions.tableName,\n          type: this.type == 'import' ? 2 : this.type == 'export' ? 1 : 'null' // 类型不对报错 类型（1：导出 2：导入）\n\n        },\n        fields: dataParams\n      };\n      portal.saveTemplate(data).then(function (res) {\n        console.log(res);\n\n        if (res.state) {\n          _this2.$message.success('保存成功');\n\n          _this2.closeDialog();\n\n          _this2.$emit('reload');\n        }\n      });\n    },\n    // 返回json赋值\n    handleGetJSon: function handleGetJSon(json, scope) {\n      var tempRow = utils.deepClone(scope.row);\n      tempRow.fieldDataJson = json;\n      this.data.splice(scope.$index, 1, tempRow);\n    },\n    // 编辑json\n    openSetJson: function openSetJson(scope) {\n      this.$refs.setJson.openDialog(scope);\n    },\n    // 打开配置\n    openDialog: function openDialog(tempId) {\n      this.tempId = tempId;\n      this.dialogShow = true;\n\n      if (tempId) {\n        this.loadTempData(tempId);\n      } // 取消拖拽排序\n      // this.$nextTick(() => {\n      //     this.setDraggable()\n      // })\n\n    },\n    // 查询已有配置\n    loadTempData: function loadTempData(id) {\n      var _this3 = this;\n\n      this.loading = true;\n      portal.loadTempData(id).then(function (res) {\n        _this3.tempData = res.excelTemp;\n        _this3.data = _this3.formatData(res.fields);\n        _this3.loading = false;\n      });\n    },\n    // 格式化回填数据\n    formatData: function formatData(data) {\n      data.forEach(function (item, index) {\n        item.key = index;\n        item.fieldViewType = parseInt(item.fieldViewType);\n      });\n      return data;\n    },\n    // 关闭页面重置数据\n    closeDialog: function closeDialog() {\n      this.data = [];\n      this.dialogShow = false;\n    },\n    // 打开添加字段弹窗\n    openAddFieldsDialog: function openAddFieldsDialog() {\n      this.$refs.AddFields.openDialog();\n    },\n    // 对象数组去重\n    unique: function unique(arr) {\n      var res = new Map();\n      return arr.filter(function (arr) {\n        return !res.has(arr.fieldName) && res.set(arr.fieldName, 1);\n      });\n    },\n    // 添加字段\n    handleAddFields: function handleAddFields(row) {\n      var addFields = utils.deepClone(row);\n      var originFields = utils.deepClone(this.data);\n      var newTarget = originFields.concat(addFields);\n\n      if (this.type == 'export') {\n        newTarget.sort(function (a, b) {\n          var nameA = a.fieldName.toUpperCase();\n          var nameB = b.fieldName.toUpperCase();\n\n          if (nameA < nameB) {\n            return -1;\n          }\n\n          if (nameA > nameB) {\n            return 1;\n          }\n\n          return 0;\n        });\n      } else if (this.type == 'import') {\n        newTarget = this.unique(newTarget);\n      }\n\n      newTarget.forEach(function (item, index) {\n        item.key = index;\n        item.fieldViewType = 1;\n        item.orderIndex = index;\n      });\n      this.data = newTarget;\n      console.log(this.data, 'this.data');\n      this.$forceUpdate();\n    },\n    handleUp: function handleUp(row, index) {\n      if (index !== 0) {\n        var targetItem = row; // 当前Item\n\n        var upItem = this.data[index - 1]; // 前一个Item\n\n        var targetIndex = this.data[index].orderIndex; // 当前ItemIndex\n\n        var upIndex = this.data[index - 1].orderIndex; // 前一个ItemIndex\n        // 交换orderIndex\n\n        targetItem.orderIndex = upIndex;\n        upItem.orderIndex = targetIndex;\n        this.data.splice(index - 1, 2, targetItem, upItem);\n      } else {\n        this.$message.warning('已经处于置顶，无法上移');\n      }\n    },\n    handleDown: function handleDown(row, index) {\n      if (index !== this.data.length - 1) {\n        var targetItem = row; // 当前Item\n\n        var downItem = this.data[index + 1]; // 前一个Item\n\n        var targetIndex = this.data[index].orderIndex; // 当前ItemIndex\n\n        var downIndex = this.data[index + 1].orderIndex; // 前一个ItemIndex\n        // 交换orderIndex\n\n        targetItem.orderIndex = downIndex;\n        downItem.orderIndex = targetIndex;\n        this.data.splice(index, 2, downItem, targetItem);\n      } else {\n        this.$message.warning('已经处于置底，无法下移');\n      }\n    },\n    // 删除字段\n    handleDelFields: function handleDelFields(row) {\n      var _this4 = this;\n\n      if (row.id) {\n        portal.DeleteExportFields(row.id).then(function (res) {\n          if (res.state) {\n            var data = utils.deepClone(_this4.data);\n            var target = data.filter(function (item) {\n              return item.key != row.key;\n            });\n            _this4.data = target;\n\n            _this4.$message.success('删除成功');\n          }\n        });\n      } else {\n        var data = utils.deepClone(this.data);\n        var target = data.filter(function (item) {\n          return item.key != row.key;\n        });\n        this.data = target;\n        this.$message.success('删除成功');\n      }\n    },\n    debounce: function debounce(fn, delay) {\n      clearTimeout(this.timer);\n      this.timer = setTimeout(function () {\n        fn();\n      }, delay);\n    },\n    // 设置表格拖拽\n    setDraggable: function setDraggable() {\n      var table = this.$refs.DTTable;\n      var $data = table.data;\n      var tbody = table.$el.querySelector('.el-table__body-wrapper tbody');\n      var $this = this;\n      var trArr = tbody.querySelectorAll('tr');\n      var dragStartY = 0;\n\n      if (trArr) {\n        trArr.forEach(function (item, index) {\n          item.setAttribute('draggable', true);\n          item.setAttribute('data-index', index);\n        });\n      } // 开始拖拽\n\n\n      function dragstart(e) {\n        console.log(e, 'dfsf');\n        $this.debounce(function () {\n          dragStartY = e.y;\n        }, 50);\n      } // 结束拖拽\n\n\n      function dragend(e) {\n        if (!e.target) return;\n        var index = Number(e.target.dataset.index, 10);\n        var trHeight = e.target.offsetHeight || 45;\n        $this.debounce( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {\n          var dVal, absVal, step, params;\n          return regeneratorRuntime.wrap(function _callee$(_context) {\n            while (1) {\n              switch (_context.prev = _context.next) {\n                case 0:\n                  dVal = e.y - dragStartY;\n                  absVal = Math.abs(dVal);\n                  step = 0;\n\n                  if (!(absVal >= trHeight)) {\n                    _context.next = 12;\n                    break;\n                  }\n\n                  if (dVal > 0) {\n                    step = Math.floor(dVal / trHeight);\n\n                    if (step >= $data.length - index) {\n                      step = $data.length - index - 1;\n                    }\n                  } else {\n                    step = Math.ceil(dVal / trHeight);\n\n                    if (Math.abs(step) > index) {\n                      step = index * -1;\n                    }\n                  }\n\n                  if (!(index === 0 && step <= 0)) {\n                    _context.next = 7;\n                    break;\n                  }\n\n                  return _context.abrupt(\"return\");\n\n                case 7:\n                  if (!(index === $data.length - 1 && step >= 0)) {\n                    _context.next = 9;\n                    break;\n                  }\n\n                  return _context.abrupt(\"return\");\n\n                case 9:\n                  // const params = {\n                  //     id: $data[index].id,\n                  //     step: step * -1,\n                  // }\n                  params = {\n                    index: index,\n                    step: step * -1\n                  };\n                  console.log(params, 'params');\n                  $this.changeSort(params); // $this.loading = true\n                  // // 后端接口\n                  // await $this.$api.url.setContentSort(params)\n                  // // 重新获取数据\n                  // $this.reloadData()\n\n                case 12:\n                case \"end\":\n                  return _context.stop();\n              }\n            }\n          }, _callee);\n        })), 50);\n      }\n\n      tbody.addEventListener('dragstart', dragstart);\n      tbody.addEventListener('dragend', dragend);\n    },\n    // 拖拽结束重新排序\n    changeSort: function changeSort(params) {\n      var data = utils.deepClone(this.data);\n      var targetIndex = params.index - params.step;\n      var targetItem = data.splice(params.index, 1);\n      data.splice(targetIndex, 0, targetItem[0]);\n      this.data = data;\n      this.$forceUpdate();\n    },\n    // 动态计算表格的高度，自适应当前容器\n    calcTableHeight: function calcTableHeight(delay) {\n      var _this5 = this;\n\n      setTimeout(function () {\n        _this5.tableHeight = document.documentElement.clientHeight * 0.9 - 200;\n      }, delay || 0);\n    }\n  }\n};",null]}