{"remainingRequest":"/data/jenkins/workspace/admin.ws.baibaodun.com.cn/node_modules/vue-loader/lib/index.js??vue-loader-options!/data/jenkins/workspace/admin.ws.baibaodun.com.cn/src/views/marketing/seckill/seckillActivity/creatSeckill.vue?vue&type=script&lang=js","dependencies":[{"path":"/data/jenkins/workspace/admin.ws.baibaodun.com.cn/src/views/marketing/seckill/seckillActivity/creatSeckill.vue","mtime":1701741776316},{"path":"/data/jenkins/workspace/admin.ws.baibaodun.com.cn/node_modules/babel-loader/lib/index.js","mtime":1701741929501},{"path":"/data/jenkins/workspace/admin.ws.baibaodun.com.cn/node_modules/cache-loader/dist/cjs.js","mtime":1701741918737},{"path":"/data/jenkins/workspace/admin.ws.baibaodun.com.cn/node_modules/vue-loader/lib/index.js","mtime":1701741928146}],"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//\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 {\n seckillIntervalListApi,\n seckillActivityAddApi,\n seckillActivityDetailApi,\n seckillAtivityUpdateApi,\n seckillProAdd,\n} from '@/api/marketing';\nimport { mapGetters } from 'vuex';\nimport { checkPermi } from '@/utils/permission'; // 权限判断函数\nimport activity from './activity.vue';\nexport default {\n name: 'creatSeckill',\n components: {\n activity,\n },\n data() {\n return {\n activeName: 'first',\n ruleForm: {\n allQuota: 0,\n endDate: '',\n merStars: 1,\n name: '',\n oneQuota: 0,\n proCategory: '',\n startDate: '',\n timeIntervals: '',\n id: '',\n productList: [],\n timeVal2: [],\n timeVal: [],\n proCategorylist: [],\n },\n rules: {\n name: [{ required: true, message: '请输入活动名称', trigger: 'blur' }],\n share: [{ required: true, message: '请选择优惠比例', trigger: 'change' }],\n timeVal: [{ required: true, message: '请选择活动日期' }],\n discount: [{ required: true, message: '请选择优惠方式' }],\n timeVal2: [{ type: 'array', required: true, message: '请选择秒杀场次', trigger: 'change' }],\n merStars: [{ required: true, message: '请选择商户星级', trigger: 'change' }],\n },\n pickerOptions: {\n disabledDate(time) {\n return time.getTime() < Date.now() - 8.64e7;\n },\n },\n spikeTimeList: [],\n multipleSelection: [],\n activityType: null,\n proData: [],\n listLoading: false,\n checkAll: false,\n isIndeterminate: true,\n tempRoute: {},\n isShowCheck: false,\n keyNum: 0,\n loading: false,\n };\n },\n created() {\n this.tempRoute = Object.assign({}, this.$route);\n },\n mounted() {\n if (!this.adminProductClassify.length) this.$store.dispatch('product/getAdminProductClassify');\n if (this.pageType) this.activeName = 'second';\n this.setTagsViewTitle();\n this.getSeckillIntervalList();\n this.isCkecked();\n if (this.$route.params.id && !this.pageType) {\n this.getInfo();\n }\n },\n computed: {\n ...mapGetters(['adminProductClassify']),\n //是否是编辑\n isEdit() {\n return this.$route.params.id ? true : false;\n },\n title() {\n return this.$route.params.id ? '编辑' : '添加';\n },\n //页面是添加商品还是编辑页面,add添加商品,edit编辑\n pageType() {\n return this.$route.params.type === 'add' ? true : false;\n },\n },\n methods: {\n checkPermi,\n setTagsViewTitle() {\n if (this.$route.params.id) {\n const title = this.pageType ? '添加商品' : this.$route.params.id ? '编辑秒杀活动' : '添加秒杀活动';\n const route = Object.assign({}, this.tempRoute, { title: `${title}-${this.$route.params.id}` });\n this.$store.dispatch('tagsView/updateVisitedView', route);\n }\n },\n // 判断选中没有\n isCkecked() {\n let checked = this.proData.filter((item) => item.checked);\n if (checked.length) {\n this.isShowCheck = false;\n } else {\n this.isShowCheck = true;\n }\n },\n //全选\n handleCheckAllChange(val) {\n this.isIndeterminate = !this.isIndeterminate;\n this.proData.forEach((item) => {\n this.$set(item, 'checked', val);\n });\n this.isCkecked();\n },\n //单选\n handleCheckOneChange(val, row) {\n let totalCount = this.proData.length;\n let someStatusCount = 0;\n this.$set(row, 'checked', val);\n this.proData.forEach((item) => {\n if (item.checked === val) {\n someStatusCount++;\n }\n });\n this.checkAll = totalCount === someStatusCount ? val : !val;\n this.isIndeterminate = someStatusCount > 0 && someStatusCount < totalCount;\n this.isCkecked();\n },\n //详情\n getInfo() {\n this.loading = true;\n seckillActivityDetailApi(this.$route.params.id)\n .then((res) => {\n let info = res;\n this.ruleForm = {\n allQuota: info.allQuota,\n endDate: info.endDate,\n merStars: info.merStars,\n name: info.name,\n oneQuota: info.oneQuota,\n proCategory: info.proCategory,\n startDate: info.startDate,\n timeIntervals: info.timeIntervals,\n id: info.id,\n productList: info.productList,\n timeVal2: info.timeIntervals.split(',').map((item) => item * 1),\n timeVal: [info.startDate, info.endDate],\n proCategorylist: info.proCategory !== '0' ? info.proCategory.split(',').map((item) => item * 1) : [],\n };\n this.getAttrValue(info.productList);\n this.loading = false;\n //this.isIndeterminate = !this.isIndeterminate;\n })\n .catch((res) => {\n this.loading = false;\n });\n },\n back() {\n this.$router.push({ path: `/marketing/seckill/seckillActivity` });\n },\n //行删除\n handleDelete(index, row) {\n this.$modalSure('删除该秒杀商品吗?').then(() => {\n let i = this.proData.findIndex((item) => item == row);\n this.proData.splice(i, 1);\n });\n },\n setActivity(data, type) {\n if (type == 1) {\n if (data.type == 0) {\n this.proData.forEach((item) => {\n item.children.forEach((item1) => {\n if (item.checked) {\n this.$set(item1, 'activityPrice', data.price);\n }\n });\n });\n } else {\n this.proData.forEach((item) => {\n item.children.forEach((item1) => {\n if (item.checked) {\n this.$set(item1, 'activityPrice', (item1.price * data.discount) / 100);\n }\n });\n });\n }\n } else if (type == 2) {\n this.proData.forEach((item) => {\n item.children.forEach((item1) => {\n if (item.checked) {\n this.$set(item1, 'quota', data.activity_stock);\n }\n });\n });\n }\n },\n // 列表\n getSeckillIntervalList() {\n seckillIntervalListApi().then((res) => {\n this.spikeTimeList = res;\n });\n },\n addGoods() {\n const _this = this;\n this.$modalGoodList(\n function (row) {\n _this.listLoading = false;\n _this.getAttrValue(row);\n },\n 'many',\n _this.proData,\n );\n },\n // 选中商品\n getAttrValue(row) {\n const _this = this;\n row.map((item) => {\n _this.$set(item, 'sort', item.sort ? item.sort : 0);\n _this.$set(item, 'id', item.id ? item.id : 0);\n _this.$set(item, 'checked', true);\n item.attrValue.map((i) => {\n _this.$set(i, 'name', i.sku);\n _this.$set(i, 'merName', item.merName);\n _this.$set(i, 'categoryName', item.categoryName);\n _this.$set(i, 'quota', i.quota ? i.quota : 0);\n _this.$set(i, 'quotaShow', i.quotaShow ? i.quotaShow : 0);\n _this.$set(i, 'activityPrice', this.$route.params.id && !this.pageType ? i.price : 0);\n _this.$set(i, 'price', this.$route.params.id && !this.pageType ? i.otPrice : i.price);\n });\n _this.$set(item, 'children', item.attrValue);\n });\n _this.proData = row;\n _this.isCkecked();\n },\n batchDel() {\n this.$modalSure(`批量删除商品吗?`).then(() => {\n this.proData = this.proData.filter((item) => !item.checked);\n });\n },\n //设置活动价\n setPrice(type) {\n this.keyNum = Math.random();\n this.$refs.activityModal.type = type;\n this.$refs.activityModal.showStatus = true;\n },\n // 具体日期\n onchangeTime2(e) {\n this.ruleForm.timeIntervals = e.toString();\n },\n // 具体日期\n onchangeTime(e) {\n this.ruleForm.timeVal = e;\n this.ruleForm.startDate = e ? e[0] : '';\n this.ruleForm.endDate = e ? e[1] : '';\n },\n submitForm(formName) {\n this.$refs[formName].validate((valid) => {\n if (valid) {\n if (this.proData.length > 0) {\n let total = 0;\n let price = 0;\n this.proData.map((item) => {\n item.children.map((i) => {\n total += i.quota;\n price += i.activityPrice;\n });\n });\n if (!total && total !== 0) return this.$message.warning('商品限量不能为空');\n if (!price) return this.$message.warning('商品秒杀价格不能为空');\n if (total < this.proData.length) return this.$message.warning('商品限量总和不能小于0');\n }\n this.ruleForm.productList = this.proData.map((item) => {\n return {\n id: item.id,\n sort: item.sort,\n attrValue: item.attrValue.map((item1) => {\n return {\n activityPrice: item1.activityPrice,\n attrValueId: item1.id,\n quota: item1.quota,\n };\n }),\n };\n });\n this.ruleForm.proCategory = this.ruleForm.proCategorylist.length\n ? this.ruleForm.proCategorylist.toString()\n : '0';\n if (this.pageType) {\n seckillProAdd({\n id: this.$route.params.id,\n productList: this.ruleForm.productList,\n })\n .then((res) => {\n this.$message.success('添加成功');\n this.$router.push({ path: `/marketing/seckill/seckillActivity` });\n })\n .catch((res) => {});\n } else {\n this.$route.params.id\n ? seckillAtivityUpdateApi(this.ruleForm)\n .then((res) => {\n this.$message.success('编辑成功');\n this.$router.push({ path: `/marketing/seckill/seckillActivity` });\n })\n .catch((res) => {})\n : seckillActivityAddApi(this.ruleForm)\n .then((res) => {\n this.$message.success('添加成功');\n this.$router.push({ path: `/marketing/seckill/seckillActivity` });\n })\n .catch((res) => {});\n }\n } else {\n return false;\n }\n });\n },\n },\n};\n",null]}