{"remainingRequest":"/Users/admin/projects/dms/src/dealer_admin/node_modules/vue-loader/lib/index.js??vue-loader-options!/Users/admin/projects/dms/src/dealer_admin/src/views/system/position/components/form.vue?vue&type=script&lang=js","dependencies":[{"path":"/Users/admin/projects/dms/src/dealer_admin/src/views/system/position/components/form.vue","mtime":1713161556000},{"path":"/Users/admin/projects/dms/src/dealer_admin/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/Users/admin/projects/dms/src/dealer_admin/node_modules/babel-loader/lib/index.js","mtime":456789000000},{"path":"/Users/admin/projects/dms/src/dealer_admin/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/Users/admin/projects/dms/src/dealer_admin/node_modules/vue-loader/lib/index.js","mtime":499162500000}],"contextDependencies":[],"result":["//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\nimport * as API from \"@/api/position.js\";\nimport _ from \"lodash\";\nexport default {\n  components: {},\n  data() {\n    return {\n      editorOption: {},\n      dialogFormVisible: false,\n      textMap: {\n        add: \"新增\",\n        update: \"编辑\",\n      },\n      value: '',\n      // 新增更新相关\n      dialogStatus: \"add\",\n      disabled: false,\n      form: {\n        name: \"\",\n        order: 0\n      },\n    };\n  },\n  computed: {\n  },\n  created() {\n    this.$forceUpdate();\n  },\n  methods: {\n    imgChange(src){\n      let form = this.form;\n      form.pic = src;\n      this.form = {};\n      this.form = form;\n    },\n    resetForm() {\n      this.form = {\n        name: \"\",\n        order: 0\n      };\n    },\n    change(e) {\n      this.$forceUpdate();\n    },\n    async init(id,parent_code = '') {\n      this.resetForm();\n      if (id) {\n        this.handleUpdate(id);\n      } else {\n        this.handleAdd();\n      }\n    },\n\n    /** 处理更新 */\n    async handleUpdate(_id) {\n      const resData = await API.detail(_id);\n      this.form = Object.assign(this.form, resData.result.detail);\n      this.dialogStatus = \"update\";\n      this.dialogFormVisible = true;\n      this.$nextTick(() => {\n        this.$refs[\"dataForm\"].clearValidate();\n      });\n    },\n\n    /** 处理新增 */\n    async handleAdd() {\n      this.dialogStatus = \"add\";\n      this.dialogFormVisible = true;\n      this.$nextTick(() => {\n        this.$refs[\"dataForm\"].clearValidate();\n      });\n    },\n\n    /** 表单提交，区分好 是 新增 、 更新 */\n    async dataFormSubmit() {\n      await this.$confirm(`确认？`, \"提示\", {\n        type: \"warning\"\n      });\n      this.$refs[\"dataForm\"].validate(async valid => {\n        if (valid) {\n          const tempData = _.cloneDeep(this.form);\n          let res;\n          if (this.dialogStatus === \"update\") {\n            tempData.id = this.form._id;\n            res = await API.update(tempData);\n          } else if (this.dialogStatus === \"add\") {\n            res = await API.create(tempData);\n          }\n          this.dialogFormVisible = false;\n\n          this.$message({\n            message: `${this.textMap[this.dialogStatus]}成功`,\n            type: \"success\",\n            duration: 1501,\n            onClose: () => {\n            }\n          });\n\n          setTimeout(() => {\n            this.$emit(\"refreshDataList\");\n          }, 500);\n        }\n      });\n    }\n  }\n};\n",null]}