From 4eac422e52a4d28fb651b75d0f054697c7a2c0fa Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期一, 09 二月 2026 15:14:13 +0800
Subject: [PATCH] 优化

---
 admin/src/components/business/OperaMemberCouponWindow.vue |  208 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 208 insertions(+), 0 deletions(-)

diff --git a/admin/src/components/business/OperaMemberCouponWindow.vue b/admin/src/components/business/OperaMemberCouponWindow.vue
new file mode 100644
index 0000000..f1d5f3e
--- /dev/null
+++ b/admin/src/components/business/OperaMemberCouponWindow.vue
@@ -0,0 +1,208 @@
+<template>
+  <GlobalWindow
+      :title="title"
+      width="60%"
+      :visible.sync="visible"
+      :confirm-working="isWorking"
+      @confirm="confirm"
+  >
+    <p class="tip-warn" style="margin: 30px;"><i class="el-icon-warning"></i>鎿嶄綔璇存槑锛氬畾鍚戝彂鏀句笉鍙楀彂鏀炬�绘暟闄愬埗锛屽畾鍚戝彂鏀句紭鎯犲埜涓嶈鍏ヤ紭鎯犲埜宸插彂鏀剧粺璁�</p>
+    <el-form :model="form" ref="form" :rules="rules" label-width="120px" label-suffix="锛�" inline>
+      <el-form-item label="鍙戞斁瀵硅薄" prop="addType" >
+        <el-radio-group v-model="form.addType" @change="changeType">
+          <el-radio :label="0">鎸囧畾浼氬憳</el-radio>
+          <el-radio :label="1">鎸囧畾鎵嬫満鍙�</el-radio>
+          <el-radio :label="2">鍏ㄩ儴浼氬憳</el-radio>
+        </el-radio-group>
+      </el-form-item>
+      <div  v-if="form.addType===0" id="bbb">
+      <el-form-item label="閫夋嫨鐢ㄦ埛" prop="addMemberIds" >
+          <el-select  v-model="form.addMemberIds" placeholder="璇疯緭鍏ヤ細鍛樻樀绉�/鎵嬫満鍙凤紝鍐嶉�夋嫨" clearable     filterable    remote  reserve-keyword    :remote-method="remoteMethod"
+              :loading="searchLoading"
+                      style="width: 400px;"
+          >
+            <el-option
+                v-for="item in users"
+                :key="item.id"
+                :label="item.nickname+'  '+(item.phone||'')"
+                :value="item.id">
+            </el-option>
+          </el-select>
+      </el-form-item>
+      </div>
+      <div  v-if="form.addType===1" id="aaaa">
+      <el-form-item  label="鎵� 鏈� 鍙�" prop="addMemberPhones" >
+        <el-input  style="width: 400px;"  type="textarea"   v-model="form.addMemberPhones"   placeholder="璇疯緭鍏ユ墜鏈哄彿"   v-trim/>
+        <p class="tip-warn" style="margin-bottom: 2px;"><i class="el-icon-warning"></i>鎻愰啋锛氬涓墜鏈哄彿锛岃鎹㈣杈撳叆</p>
+      </el-form-item>
+      </div>
+      <el-form-item label="鍙戞斁鍐呭" prop="addCouponList" style="margin-top: 20px" >
+        <div  style="border: 1px solid #f2f2f2">
+          <el-table style="width: 600px;"  :data="form.addCouponList">
+            <el-table-column prop="name" label="浼樻儬鍒�" min-width="300px" align="center">
+              <template slot-scope="{row}" >
+                <el-select v-model="row.id" style="width: 200px;margin: 0px 20px" clearable filterable   placeholder="璇烽�夋嫨浼樻儬鍒�"  >
+                  <el-option v-for="item in couponList"   :label="item.name"  :value="item.id">  </el-option>
+                </el-select>
+              </template>
+            </el-table-column>
+            <el-table-column prop="num" label="鏁伴噺" min-width="200px" align="center">
+              <template slot-scope="{row}" >
+                <el-input  style="width: 150px;margin: 0px 20px" type="number"   v-model="row.num"   placeholder="璇疯緭鍏ユ暟閲�"   v-trim/>
+              </template>
+            </el-table-column>
+            <el-table-column  label="鎿嶄綔" min-width="100px" align="center">
+              <template slot-scope="scope" >
+                <el-button style="color: red;border: none;" @click="delCoupon( scope.$index)">鍒犻櫎</el-button>
+              </template>
+            </el-table-column>
+          </el-table>
+          <el-button s type="primary" icon="el-icon-plus" @click="addCoupon()" style="height: 30px;margin: 10px;">娣诲姞</el-button>
+        </div>
+      </el-form-item>
+    </el-form>
+  </GlobalWindow>
+</template>
+
+<script>
+import BaseOpera from '@/components/base/BaseOpera'
+import GlobalWindow from '@/components/common/GlobalWindow'
+import { allList } from '@/api/business/coupon'
+import { findAll as memberlist } from '@/api/business/member'
+export default {
+  name: 'OperaCouponWindow',
+  extends: BaseOpera,
+  components: { GlobalWindow },
+  data () {
+    const couponRules = (rule, value, callback) => {
+      if (!this.form.addCouponList || !this.form.addCouponList.length) {
+        callback(new Error('璇烽�夋嫨浼樻儬鍒镐俊鎭�'))
+      } else {
+        var r = true
+        this.form.addCouponList.forEach(item => {
+          if (!item.id || !item.num) {
+            r = false
+          }
+        })
+        if (!r) {
+          callback(new Error('璇峰畬鍠勪紭鎯犲埜淇℃伅'))
+        } else {
+          callback()
+        }
+      }
+    }
+    return {
+      searchLoading: false,
+      couponList: [],
+      users: [],
+      // 琛ㄥ崟鏁版嵁
+      form: {
+        addType: 0,
+        addMemberIds: null,
+        addMemberPhones: null,
+        addCouponList: [{ id: null, num: null }]
+      },
+      shops: [],
+      categorys: [],
+      // 楠岃瘉瑙勫垯
+      rules: {
+        addType: [
+          { required: true, message: '璇烽�夋嫨鍙戞斁瀵硅薄' }
+        ],
+        addMemberIds: [
+          { required: true, message: '璇烽�変腑浜哄憳淇℃伅' }
+        ],
+        addMemberPhones: [
+          { required: true, message: '璇锋寚瀹氫汉鍛樻墜鏈哄彿' }
+        ],
+        addCouponList: [
+          { required: true, validator: couponRules, tigger: 'blur' }
+        ]
+      }
+    }
+  },
+  created () {
+    this.config({
+      api: '/business/memberCoupon',
+      'field.id': 'id'
+    })
+  },
+  methods: {
+    changeType(t){
+      this.$refs.form.validate()
+    },
+    remoteMethod (query) {
+      if (query !== '') {
+        this.searchLoading = true
+        memberlist({
+          capacity: 999,
+          model: {
+            nickname: query,
+            status: 0
+          }
+        })
+          .then(res => {
+            this.users = res
+          })
+          .finally(() => {
+            this.searchLoading = false
+          })
+      }
+    },
+    getCouponList () {
+      allList({ status: 0 })
+        .then(res => {
+          if (res) {
+            this.couponList = res || []
+          }
+        })
+    },
+    delCoupon (index) {
+      this.form.addCouponList.splice(index, 1)
+    },
+    addCoupon (type) {
+      this.form.addCouponList.push({ id: null, num: null })
+    },
+    open (title, target, type) {
+      this.title = title
+      this.visible = true
+      this.form.addMemberIds = null
+      this.form.addMemberPhones = null
+      this.form.addType = 0
+      this.form.addCouponList = [{ id: null, num: null }]
+      this.getCouponList()
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+@import '@/assets/style/alertstyle.scss';
+
+.coupon-rule {
+  display: flex;
+  .discrep {
+    padding: 0 10px;
+  }
+  ::v-deep .el-input {
+    width: 160px;
+  }
+}
+.num-style {
+  ::v-deep .el-input-number {
+    width: 60%;
+  }
+}
+.date-style {
+  ::v-deep input {
+    text-align: center !important;
+  }
+}
+::v-deep .el-select {
+  width: 100%;
+  .el-input__inner {
+    width: 100%;
+  }
+}
+
+</style>

--
Gitblit v1.9.3