{"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/dealer/schedule/components/NoticeModal.vue?vue&type=script&lang=js","dependencies":[{"path":"/Users/admin/projects/dms/src/dealer_admin/src/views/dealer/schedule/components/NoticeModal.vue","mtime":1713161556000},{"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//\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 * as API from \"@/api/schedule.js\";\nimport _ from \"lodash\";\nimport DealerListSelect from \"@/views/components/DealerListSelect.vue\";\nimport IndustrySelect from \"@/views/components/IndustrySelect.vue\";\nimport {parseTime} from \"@/utils\";\n\nexport default {\n  components: {\n      DealerListSelect,\n      IndustrySelect\n  },\n  data() {\n    return {\n      dialogFormVisible: false,\n      // 新增更新相关\n      form: {\n        date: \"\",\n        content: \"\",\n        objectType: null,   // 1: 群发 2:经销商列表 3:行业\n        dealerIdList:[],\n        industry:null,\n      },\n      objectTypeList:[\n          {\n              name: '群发',\n              value: 1\n          },\n          {\n              name: '经销商列表',\n              value: 2\n          },\n          {\n              name: '行业',\n              value: 3\n          },\n      ]\n    };\n  },\n  computed: {\n  },\n  \n  created() {\n    this.$forceUpdate();\n  },\n  methods: {\n    resetForm() {\n      this.form = {\n          date: \"\",\n          content: \"\",\n          objectType: null,   // 1:经销商列表2:行业\n          dealerIdList:[],\n          industry:null,\n      };\n    },\n    change(e) {\n      this.$forceUpdate();\n    },\n    async init(id) {\n      this.resetForm();\n      this.handleUpdate(id);\n    },\n\n    /** 处理更新 */\n    async handleUpdate(_id) {\n      const resData = await API.detail(_id);\n      let {detail} = resData.result;\n      this.form = Object.assign(this.form, detail,{\n          date: (detail.date ? parseTime(detail.date,'{y}-{m}-{d}') : \"\")\n      });\n      this.dialogFormVisible = true;\n      this.$nextTick(() => {\n        this.$refs[\"dataForm\"].clearValidate();\n      });\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          tempData.id = this.form._id;\n          console.log(tempData);\n          if(!tempData.objectType){\n              this.$message({\n                  message: \"请先选择通知对象筛选\",\n                  type: \"error\"\n              });\n              return;\n          }\n          if(tempData.objectType == 2){\n              if(!tempData.dealerIdList || tempData.dealerIdList.length <= 0){\n                  this.$message({\n                      message: \"请至少选择一个经销商\",\n                      type: \"error\"\n                  });\n                  return;\n              }\n          }\n          tempData.dealerIdList = JSON.stringify(tempData.dealerIdList);\n\n          if(tempData.objectType == 3){\n              if(!tempData.industry ){\n                  this.$message({\n                      message: \"请选择行业\",\n                      type: \"error\"\n                  });\n                  return;\n              }\n          }\n\n          let res = await API.notice(tempData);\n          let {__error,msg} = res;\n          if(__error == 0){\n              this.dialogFormVisible = false;\n              this.$message({\n                  message: `${msg}`,\n                  type: \"success\",\n              });\n              setTimeout(() => {\n                  this.$emit(\"refreshDataList\");\n              }, 500);\n              return;\n          }            \n\n        }\n      });\n    }\n  }\n};\n",null]}