From 297734ace4c05848b28a792fa89f38bee67be3c1 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期六, 28 二月 2026 09:41:34 +0800
Subject: [PATCH] 合并

---
 admin/src/components/business/OperaCouponWindow.vue |  137 ++++++++++++++++++++++++++++-----------------
 1 files changed, 85 insertions(+), 52 deletions(-)

diff --git a/admin/src/components/business/OperaCouponWindow.vue b/admin/src/components/business/OperaCouponWindow.vue
index 68002b6..a6649b7 100644
--- a/admin/src/components/business/OperaCouponWindow.vue
+++ b/admin/src/components/business/OperaCouponWindow.vue
@@ -28,20 +28,22 @@
           <el-input  v-model="form.price"     placeholder="璇疯緭鍏�"    @input="inputAction(form, 'price')"  >
             <template slot="append" >{{form.couponType ===1?'鎶�':'鍏�'}}</template>
           </el-input>
+          <div class="discrep"  v-if="form.couponType === 1" >锛屾姌鎵d紭鎯犻噾棰濅笂闄�</div>
+          <el-input  v-model="form.maxPrice"     v-if="form.couponType === 1"  placeholder="璇疯緭鍏�"    @input="inputAction(form, 'maxPrice')"  >
+            <template slot="append" >鍏�</template>
+          </el-input>
         </div>
       </el-form-item>
       <el-form-item label="浼樻儬鍒歌鏄�" prop="info">
-        <el-input type="textarea" v-model="form.info" placeholder="璇疯緭鍏ヤ紭鎯犲埜璇存槑"  v-trim/>
+        <el-input type="textarea" v-model="form.info" placeholder="璇疯緭鍏ヤ紭鎯犲埜璇存槑" maxlength="500"  v-trim/>
       </el-form-item>
       <p class="tip-header" >浣跨敤闄愬埗</p>
-      <el-form-item label="鏈夋晥鏈�" prop="useType">
-        <el-radio-group v-model="form.useType">
+      <el-form-item label="鏈夋晥鏈�" prop="getDate">
+        <el-radio-group v-model="form.useType" @change="changeApplyType">
           <el-radio :label="0">鍥哄畾鏃舵</el-radio>
           <el-radio :label="1">鍥哄畾鏃堕暱</el-radio>
         </el-radio-group>
-      </el-form-item>
-      <el-form-item label="浣跨敤鏃舵" prop="getDate" v-if="form.useType===0">
-        <div class="date-style">
+        <div class="date-style" v-if="form.useType===0">
           <el-date-picker
               v-model="getDate"
               type="datetimerange"
@@ -53,9 +55,7 @@
               @change="selectDate"
           ></el-date-picker>
         </div>
-      </el-form-item>
-      <el-form-item label="鍥哄畾鏃堕暱" prop="validDays" v-if="form.useType===1">
-        <div class="coupon-rule">
+        <div class="coupon-rule" v-if="form.useType===1">
           <div class="discrep">棰嗗姷鍚�</div>
           <el-input
               v-model="form.validDays"
@@ -68,26 +68,36 @@
         </div>
       </el-form-item>
       <el-form-item label="閫傜敤瀵硅薄" prop="applyType">
-        <el-radio-group v-model="form.applyType">
+        <el-radio-group v-model="form.applyType" @change="changeApplyType">
           <el-radio :label="0">鍏ㄥ満閫氱敤</el-radio>
           <el-radio :label="1">鎸夊搧绫�</el-radio>
           <el-radio :label="2">鎸囧畾鍟嗗搧</el-radio>
         </el-radio-group>
       </el-form-item>
-      <el-form-item v-if="form.applyType===1" label="閫夋嫨鍝佺被" prop="applyCateIdList" >
-        <el-select v-model="form.applyCateIdList"  placeholder="璇烽�夋嫨,鏀寔澶氶��" filterable multiple clearable >
+      <el-form-item label="閫夋嫨鍝佺被"   prop="applyTypeRule" v-if="form.applyType===1">
+          <el-select style="margin-left:10px;width: 300px;" v-model="form.applyCateIdList"  placeholder="璇烽�夋嫨鍟嗗搧鍒嗙被,鏀寔澶氶��" filterable multiple clearable >
+            <el-option  v-for="item in categorys" :key="'optCate'+item.id"  :label="item.name"  :value="item.id">  </el-option>
+          </el-select>
+      </el-form-item>
+      <el-form-item label="閫変腑鍟嗗搧" prop="applyTypeRule"  v-if="form.applyType===2">
+          <span style="font-size: 12px;color: #216EEE"   @click="selectGoods">宸叉寚瀹氥�� {{applyDataList.length}} 銆戜欢鍟嗗搧</span>
+          <el-button style="margin-left:30px;display: inline-block;width: 80px;" type="primary"  @click="selectGoods">鍘婚�夋嫨 </el-button>
+      </el-form-item>
+<!--      <el-form-item v-if="form.applyType===1" label="閫夋嫨鍝佺被" prop="applyCateIdList" >
+        <el-select v-model="form.applyCateIdList"  placeholder="璇烽�夋嫨鍟嗗搧鍒嗙被,鏀寔澶氶��" filterable multiple clearable >
           <el-option  v-for="item in categorys" :key="'optCate'+item.id"  :label="item.name"  :value="item.id">  </el-option>
         </el-select>
       </el-form-item>
       <el-form-item v-if="form.applyType===2" label="閫夋嫨鍟嗗搧" prop="applyIdList" style="display: flex">
           <span style="font-size: 12px;color: #216EEE"   @click="selectGoods">宸叉寚瀹氥�� {{applyDataList.length}} 銆戜欢鍟嗗搧</span>
         <el-button style="margin-left:30px;display: inline-block;width: 80px;" type="primary"  @click="selectGoods">鍘婚�夋嫨 </el-button>
-      </el-form-item>
+      </el-form-item>-->
       <p class="tip-header" >鍙戞斁瑙勫垯</p>
       <el-form-item label="鍙戞斁鎬婚噺" prop="num">
         <div class="num-style">
-          <el-input-number  v-model="form.num" :controls="false" :min="1" :max="99999" placeholder="璇疯緭鍏ュ彂鏀炬�婚噺(1~99999)" v-trim></el-input-number>
+          <el-input-number  v-model="form.num" :controls="false" :min="0" :max="99999" placeholder="璇疯緭鍏ュ彂鏀炬�婚噺(0~99999)" v-trim></el-input-number>
         </div>
+        <p class="tip-warn" style="margin-bottom: 1px;"><i class="el-icon-warning"></i>鎻愰啋锛氬彂鏀炬�婚噺涓�0琛ㄧず涓嶉檺鍒�</p>
       </el-form-item>
     </el-form>
     <OperaCouponGoodsWindow ref="OperaCouponGoodsWindow" @success="doSelect"/>
@@ -99,27 +109,44 @@
 import { fetchList as shopList } from '@/api/business/shop'
 import GlobalWindow from '@/components/common/GlobalWindow'
 import { findAll as labelList } from '@/api/business/labels'
-import { allList as goodsList} from '@/api/business/goods'
+import { allList as goodsList } from '@/api/business/goods'
 import OperaCouponGoodsWindow from '@/components/business/OperaCouponGoodsWindow'
 export default {
   name: 'OperaCouponWindow',
   extends: BaseOpera,
-  components: { GlobalWindow,OperaCouponGoodsWindow },
+  components: { GlobalWindow, OperaCouponGoodsWindow },
   data () {
     const couponRules = (rule, value, callback) => {
       if (!this.form.limitPrice) {
         callback(new Error('璇疯緭鍏ユ弧棰�'))
       } else if (!this.form.price) {
         callback(new Error('璇峰畬鍠勪紭鎯犺鍒�'))
+      } else if (this.form.couponType == 1 && (this.form.price <= 0 || this.form.price >= 10)) {
+        callback(new Error('浼樻儬鎶樻墸鍙兘涓� (0,10)鑼冨洿鍐�'))
       } else {
         callback()
       }
     }
     const getDateRules = (rule, value, callback) => {
-      if (!this.form.startDate) {
+      if (!this.form.useType < 0) {
+        callback(new Error('璇烽�夋嫨鏈夋晥鏈�'))
+      } else if (this.form.useType == 1 && !this.form.validDays) {
+        callback(new Error('璇疯緭鍏ュ浐瀹氭椂闀垮ぉ鏁�'))
+      } else if (this.form.useType == 0 && !this.form.startDate) {
         callback(new Error('璇烽�夋嫨寮�濮嬫椂闂�'))
-      } else if (!this.form.endDate) {
+      } else if (this.form.useType == 0 && !this.form.endDate) {
         callback(new Error('璇疯緭鍏ョ粨鏉熸椂闂�'))
+      } else {
+        callback()
+      }
+    }
+    const getApplyTypeRule = (rule, value, callback) => {
+      if (!this.form.applyType < 0) {
+        callback(new Error('璇烽�夋嫨閫傜敤鑼冨洿'))
+      } else if (this.form.applyType == 1 && (!this.form.applyCateIdList  || !this.form.applyCateIdList.length)) {
+        callback(new Error('璇烽�夋嫨浣跨敤鍝佺被'))
+      } else if (this.form.applyType == 2 && (!this.form.applyIdList  || !this.form.applyIdList.length)) {
+        callback(new Error('璇烽�夋嫨鎸囧畾鍟嗗搧'))
       } else {
         callback()
       }
@@ -134,8 +161,8 @@
     return {
       searchLoading: false,
       getDate: [],
-      applyDataList:[],
-      showGoods:false,
+      applyDataList: [],
+      showGoods: false,
       // 琛ㄥ崟鏁版嵁
       form: {
         id: null,
@@ -181,15 +208,15 @@
         num: [
           { required: true, validator: numRule, message: '璇疯緭鍏ュ彂鏀炬�绘暟', tigger: 'blur' }
         ],
-        /*integral: [
+        /* integral: [
           { required: true, validator: numRule, message: '璇疯緭鍏ュ厬鎹㈡潯浠�', tigger: 'blur' }
-        ],*/
-        // validDays: [
-        //   { required: true, message: '璇疯緭鍏ュ彲鐢ㄦ椂闂�', tigger: 'blur' }
-        // ],
-        // getDate: [
-        //   { required: true, validator: getDateRules, tigger: 'change' }
-        // ],
+        ], */
+        getDate: [
+          { required: true, validator: getDateRules }
+        ],
+        applyTypeRule: [
+          { required: true, validator: getApplyTypeRule }
+        ]
         // shopId: [
         //   { required: true, validator: numRule, message: '璇烽�夋嫨鍏宠仈搴楅摵', tigger: 'change' }
         // ]
@@ -203,19 +230,19 @@
     })
   },
   methods: {
-    selectGoods(){
+    selectGoods () {
       this.$refs.OperaCouponGoodsWindow.open('閫夋嫨鍟嗗搧', this.applyDataList)
     },
-    loadLabels(){
+    loadLabels () {
       labelList({
         type: 0 // 鍟嗗搧鍒嗙被
       }).then(res => {
         this.categorys = res || []
       })
     },
-    loadSelectGoods(){
+    loadSelectGoods () {
       console.log(this.form.applyIdList)
-      if(!this.form.applyIdList || !this.form.applyIdList.length){
+      if (!this.form.applyIdList || !this.form.applyIdList.length) {
         return
       }
       goodsList({
@@ -224,34 +251,38 @@
         this.applyDataList = res || []
       })
     },
-    doSelect(rows){
-      console.log(rows,this.applyDataList)
-      this.applyDataList =[]
-      this.form.applyIdList=[]
-      if(rows && rows.length){
+    changeApplyType(){
+      this.$refs.form.clearValidate()
+    },
+    doSelect (rows) {
+      console.log(rows, this.applyDataList)
+      this.applyDataList = []
+      this.form.applyIdList = []
+      if (rows && rows.length) {
         rows.forEach(item => {
           this.applyDataList.push(item)
           this.form.applyIdList.push(item.id)
         })
       }
+      this.$refs.form.clearValidate();
     },
     open (title, target, type) {
-      this.showGoods=false
+      this.showGoods = false
       this.title = title
       this.visible = true
       this.form.type = type
       this.getDate = []
       this.form.startDate = ''
       this.form.endDate = ''
-      this.applyDataList=[]
-      this.form.applyIdList=[]
-      this.form.applyCateIdList=[]
+      this.applyDataList = []
+      this.form.applyIdList = []
+      this.form.applyCateIdList = []
       this.loadLabels()
-      this.form.limitPrice=null
-      this.form.price=null
-      this.form.startDate=null
-      this.form.endDate=null
-      this.form.num=1
+      this.form.limitPrice = null
+      this.form.price = null
+      this.form.startDate = null
+      this.form.endDate = null
+      this.form.num = 1
       // 鏂板缓
       if (target == null) {
         this.$nextTick(() => {
@@ -266,17 +297,19 @@
         for (const key in this.form) {
           this.form[key] = target[key]
         }
-        this.getDate = [target.startDate, target.endDate]
-        if(this.form.applyType === 1){
-          this.form.applyCateIdList =[]
+        if (target.startDate && target.endDate) {
+          this.getDate = [target.startDate, target.endDate]
+        }
+        if (this.form.applyType === 1) {
+          this.form.applyCateIdList = []
           var ta = this.form.applyIds.split(',')
-          if(ta && ta.length){
-            ta.forEach(tt =>{
+          if (ta && ta.length) {
+            ta.forEach(tt => {
               this.form.applyCateIdList.push(parseInt(tt))
             })
           }
         }
-        if(this.form.applyType === 2){
+        if (this.form.applyType === 2) {
           this.form.applyIdList = this.form.applyIds.split(',')
           this.loadSelectGoods()
         }

--
Gitblit v1.9.3