Sfoglia il codice sorgente

礼品卡数据对接

chenrui 4 anni fa
parent
commit
bb1d162c5a

+ 45 - 0
src/api/giftCard.js

@@ -0,0 +1,45 @@
+import { axios } from '@/utils/request'
+
+// 获取列表数据
+export const giftCardQuery = params => {
+  const url = `giftCard/query/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+// 新增礼品卡
+export const giftCardAdd = params => {
+  return axios({
+    url: `giftCard/batchAdd`,
+    data: params,
+    method: 'post'
+  })
+}
+// 编辑礼品卡
+export const giftCardEdit = params => {
+  return axios({
+    url: `giftCard/editGiftCardItem`,
+    data: params,
+    method: 'post'
+  })
+}
+// 礼品卡详情
+export const giftCardDetail = params => {
+  return axios({
+    url: `giftCard/detail/${params.id}`,
+    data: {},
+    method: 'get'
+  })
+}
+// 删除礼品卡
+export const giftCardDel = (params) => {
+  return axios({
+    url: `giftCard/delGiftCardItemById/${params.id}`,
+    data: {},
+    method: 'get'
+  })
+}

+ 2 - 0
src/store/modules/user.js

@@ -51,6 +51,7 @@ const user = {
               const users = res.auth_user
               Vue.ls.set('hasError', 0)
               commit('SET_TOKEN', res.access_token)
+              commit('SET_INFO', users)
               commit('SET_NAME', { name: users.userNameCN, welcome: welcome() })
               commit('SET_MUSTCHANGEPWD', users.mustChangePwd)
               Vue.ls.set('rolesAccess', { permissionList: users.permCodes }, 7 * 24 * 60 * 60 * 1000)
@@ -96,6 +97,7 @@ const user = {
           commit('SET_MUSTCHANGEPWD', '')
           commit('SET_AVATAR', '')
           commit('SET_TOKEN', '')
+          commit('SET_INFO', {})
           commit('SET_ROLES', { permissionList: [] })
           Vue.ls.remove(ACCESS_TOKEN)
           Vue.ls.remove('userName')

+ 27 - 27
src/views/market/giftCard/addCardModal.vue

@@ -17,12 +17,12 @@
       :wrapper-col="formItemLayout.wrapperCol"
       @submit="handleSubmit">
       <a-form-model-item label="创建人">
-        <p class="creater">张先生</p><p class="telephone">15778785468</p>
+        <p class="creater">{{ userInfo.userNameCN }}</p><p class="telephone">{{ userInfo.mobile }}</p>
       </a-form-model-item>
-      <a-form-model-item label="礼品卡内容" prop="name">
+      <a-form-model-item label="礼品卡内容" prop="goldNum">
         <a-input-number
-          id="add-card-name"
-          v-model="formData.name"
+          id="add-card-goldNum"
+          v-model="formData.goldNum"
           :min="1"
           :max="999999"
           :precision="0"
@@ -30,10 +30,10 @@
           placeholder="请输入礼品卡内容(1~999999)"
           allowClear /><span>乐豆</span>
       </a-form-model-item>
-      <a-form-model-item label="礼品卡数量" prop="name">
+      <a-form-model-item label="礼品卡数量" prop="createNum">
         <a-input-number
-          id="add-card-provinceCode"
-          v-model="formData.provinceCode"
+          id="add-card-createNum"
+          v-model="formData.createNum"
           :min="1"
           :max="999999"
           :precision="0"
@@ -50,7 +50,8 @@
 </template>
 
 <script>
-// import { stationSave, stationFind } from '@/api/station'
+import { giftCardAdd } from '@/api/giftCard'
+import { mapGetters } from 'vuex'
 export default {
   name: 'AddCardModal',
   props: {
@@ -59,6 +60,9 @@ export default {
       default: false
     }
   },
+  computed: {
+    ...mapGetters(['userInfo'])
+  },
   data () {
     return {
       isShow: this.openModal, //  是否打开弹框
@@ -67,37 +71,32 @@ export default {
         wrapperCol: { span: 16 }
       },
       formData: {
-        name: null, //  网点名称
-        provinceCode: null //  省
+        goldNum: null, //  礼品卡内容
+        createNum: 1 //  礼品卡数量
       },
       rules: {
-        name: [
+        goldNum: [
           { required: true, message: '请输入礼品卡内容', trigger: 'blur' }
+        ],
+        createNum: [
+          { required: true, message: '请输入礼品卡数量', trigger: 'blur' }
         ]
       }
     }
   },
   methods: {
-    //  物流信息  保存
+    //  保存
     handleSubmit (e) {
       e.preventDefault()
       const _this = this
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
-          const params = {
-      			  name: this.formData.name,
-      			  loginFlag: this.formData.loginFlag,
-      			  phone: this.formData.phone
-          }
-          // saveUserPower(params).then(res => {
-          //   if (res.status == 200) {
-          //     if (this.$hasPermissions('M_bundel_buyRecord')) {
-          //       this.$router.push({ path: '/SetmealSales/PurchasedSetmeal' })
-          //     } else {
-          //       this.cancel()
-          //     }
-          //   }
-          // })
+          giftCardAdd(_this.formData).then(res => {
+            if (res.status == 200) {
+              _this.isShow = false
+              this.$emit('refresh', true)
+            }
+          })
         } else {
           console.log('error submit!!')
           return false
@@ -113,8 +112,9 @@ export default {
     //  重定义的弹框状态
     isShow (newValue, oldValue) {
       if (!newValue) {
-        this.$refs.ruleForm.resetFields()
         this.$emit('close')
+      } else {
+        this.$refs.ruleForm.resetFields()
       }
     }
   }

+ 34 - 37
src/views/market/giftCard/editCardModal.vue

@@ -15,14 +15,15 @@
       ref="ruleForm"
       :label-col="formItemLayout.labelCol"
       :wrapper-col="formItemLayout.wrapperCol"
-      @submit="handleSubmit">
-      <a-form-model-item label="创建时间"> 2021/01/11 </a-form-model-item>
+      @submit="handleSubmit"
+      v-if="detailsData">
+      <a-form-model-item label="创建时间"> {{ detailsData.createDate }} </a-form-model-item>
       <a-form-model-item label="创建人">
-        <p class="creater">张先生</p><p class="telephone">15778785468</p>
+        <p class="creater">{{ userInfo.userNameCN }}</p><p class="telephone">{{ userInfo.mobile }}</p>
       </a-form-model-item>
-      <a-form-model-item label="礼品卡内容"> 100乐豆 </a-form-model-item>
-      <a-form-model-item ref="name" label="实体卡编号" prop="name">
-        <a-input id="edit-card-number" :maxLength="30" v-model="formData.name" placeholder="请输入实体卡编号(最多30个字符)" allowClear />
+      <a-form-model-item label="礼品卡内容"> {{ detailsData.content }} </a-form-model-item>
+      <a-form-model-item label="实体卡编号" prop="optionalSequence">
+        <a-input id="edit-card-optionalSequence" :maxLength="30" v-model="formData.optionalSequence" placeholder="请输入实体卡编号(最多30个字符)" allowClear />
       </a-form-model-item>
       <a-form-model-item label="备注" prop="remarks">
         <a-textarea id="edit-card-remarks" :maxLength="500" v-model="formData.remarks" placeholder="请输入备注(最多500个字符)" allowClear />
@@ -36,7 +37,8 @@
 </template>
 
 <script>
-// import { stationSave } from '@/api/station'
+import { mapGetters } from 'vuex'
+import { giftCardDetail, giftCardEdit } from '@/api/giftCard'
 export default {
   name: 'EditCardModal',
   props: {
@@ -49,6 +51,9 @@ export default {
       default: ''
     }
   },
+  computed: {
+    ...mapGetters(['userInfo'])
+  },
   data () {
     return {
       isShow: this.openModal, //  是否打开弹框
@@ -57,28 +62,27 @@ export default {
         wrapperCol: { span: 16 }
       },
       formData: {
-        name: '', //  实体卡编号
+        id: this.cardId,
+        optionalSequence: '', //  实体卡编号
         remarks: '' //  备注
       },
-      rules: {
-        name: [
-          { required: true, message: '请输入实体卡编号', trigger: 'blur' }
-        ]
-      }
+      rules: {},
+      detailsData: null //  详情
     }
   },
   methods: {
     //  获取详情
     getDetails () {
-      // stationFind({ id: this.cardId }).then(res => {
-      //   if (res.status == 200) {
-      //     //  省市区
-      //     this.form.setFieldsValue({ 'formData.lat': res.data.lat })
-      //     this.form.setFieldsValue({ 'formData.lng': res.data.lng })
-      //     this.form.setFieldsValue({ 'formData.goldExRuleNo': res.data.goldExRuleNo })
-      //     this.form.setFieldsValue({ 'formData.deliveryTimeRuleNo': res.data.deliveryTimeRuleNo })
-      //   }
-      // })
+      giftCardDetail({ id: this.cardId }).then(res => {
+        if (res.status == 200) {
+          this.formData.id = res.data.id
+          this.formData.optionalSequence = res.data.optionalSequence || ''
+          this.formData.remarks = res.data.remarks || ''
+          this.detailsData = res.data
+        } else {
+          this.detailsData = null
+        }
+      })
     },
     //  物流信息  保存
     handleSubmit (e) {
@@ -86,20 +90,12 @@ export default {
       const _this = this
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
-          const params = {
-      			  name: this.formData.name,
-      			  loginFlag: this.formData.loginFlag,
-      			  phone: this.formData.phone
-          }
-          // saveUserPower(params).then(res => {
-          //   if (res.status == 200) {
-          //     if (this.$hasPermissions('M_bundel_buyRecord')) {
-          //       this.$router.push({ path: '/SetmealSales/PurchasedSetmeal' })
-          //     } else {
-          //       this.cancel()
-          //     }
-          //   }
-          // })
+          giftCardEdit(_this.formData).then(res => {
+            if (res.status == 200) {
+              _this.isShow = false
+              this.$emit('refresh')
+            }
+          })
         } else {
           console.log('error submit!!')
           return false
@@ -115,8 +111,9 @@ export default {
     //  重定义的弹框状态
     isShow (newValue, oldValue) {
       if (!newValue) {
-        this.$refs.ruleForm.resetFields()
         this.$emit('close')
+      } else {
+        this.$refs.ruleForm.resetFields()
       }
     },
     cardId (newValue, oldValue) {

+ 15 - 20
src/views/market/giftCard/getCodeModal.vue

@@ -8,30 +8,25 @@
     v-model="isShow"
     @cancle="isShow=false"
     :width="600">
-    <!-- <div v-if="detailsData"> -->
-    <div>
+    <div v-if="detailsData">
       <a-row :gutter="35">
         <a-col :span="24" class="item-cont">
           <p class="item-label">创建时间:</p>
-          <!-- <p class="item-main">{{ detailsData.name }}</p> -->
-          <p class="item-main">detailsData.name</p>
+          <p class="item-main">{{ detailsData.createDate }}</p>
         </a-col>
         <a-col :span="24" class="item-cont">
           <p class="item-label">创建人:</p>
-          <!-- <p class="item-main">{{ detailsData.provinceName }}</p> -->
-          <p class="item-main">detailsData.provinceName</p>
+          <p class="item-main">{{ detailsData.name }}  {{ detailsData.phone }}</p>
         </a-col>
         <a-col :span="24" class="item-cont">
           <p class="item-label">礼品卡内容:</p>
-          <!-- <p class="item-main">{{ detailsData.lat }} 乐豆</p> -->
-          <p class="item-main">detailsData.lat 乐豆</p>
+          <p class="item-main">{{ detailsData.content }}</p>
         </a-col>
         <a-col :span="24" class="item-cont">
           <p class="item-label">充值码:</p>
           <div class="item-main">
-            <!-- <span>{{ detailsData.lng }}</span> -->
-            <span style="margin-right: 15px;">detailsData.lng</span>
-            <a-button id="gift-card-copy" size="small" v-clipboard:copy="'detailsData'" v-clipboard:success="onCopy">复制</a-button>
+            <span style="margin-right: 15px;">{{ detailsData.sequence }}</span>
+            <a-button id="gift-card-copy" size="small" v-clipboard:copy="detailsData.sequence" v-clipboard:success="onCopy">复制</a-button>
           </div>
         </a-col>
       </a-row>
@@ -41,7 +36,7 @@
 </template>
 
 <script>
-// import { stationFind } from '@/api/station'
+import { giftCardDetail } from '@/api/giftCard'
 export default {
   name: 'GetCodeModal',
   props: {
@@ -57,19 +52,19 @@ export default {
   data () {
     return {
       isShow: this.openModal, //  是否打开弹框
-      detailsData: null //  网点数据
+      detailsData: null //  详情
     }
   },
   methods: {
     //  获取详情
     getDetails () {
-      // stationFind({ id: this.cardId }).then(res => {
-      //   if (res.status == 200) {
-      //     this.detailsData = res.data
-      //   }else{
-      //     this.detailsData = null
-      //   }
-      // })
+      giftCardDetail({ id: this.cardId }).then(res => {
+        if (res.status == 200) {
+          this.detailsData = res.data
+        } else {
+          this.detailsData = null
+        }
+      })
     },
     //  复制
     onCopy () {

+ 69 - 37
src/views/market/giftCard/giftCard.vue

@@ -7,7 +7,7 @@
           <a-col :md="6" :sm="24">
             <a-form-item label="创建时间" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
               <a-range-picker
-                id="winRecord-time"
+                id="gift-card-time"
                 v-model="time"
                 :format="dateFormat"
                 :placeholder="['开始时间','结束时间']"
@@ -19,42 +19,48 @@
             <a-form-item label="礼品卡内容" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
               <a-input
                 allowClear
-                v-model="searchData.activeName"
+                v-model="searchData.goldNum"
                 :maxLength="30"
                 placeholder="请输入礼品卡内容"
                 suffix="乐豆"
-                id="gift-card-name" />
+                id="gift-card-goldNum" />
             </a-form-item>
           </a-col>
           <a-col :md="6" :sm="24">
             <a-form-item label="实体卡编号" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
-              <a-input allowClear v-model="searchData.activeName" :maxLength="30" placeholder="请输入实体卡编号" id="gift-card-name" />
+              <a-input allowClear v-model="searchData.optionalSequence" :maxLength="30" placeholder="请输入实体卡编号" id="gift-card-optionalSequence" />
             </a-form-item>
           </a-col>
           <a-col :md="6" :sm="24">
             <a-form-item label="是否已充值" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
-              <v-select code="FLAG" v-model="searchData.state" allowClear placeholder="请选择" id="gift-card-enable-state"></v-select>
+              <v-select
+                ref="giftCardState"
+                code="GIFT_CARD_STATE"
+                v-model="searchData.state"
+                allowClear
+                placeholder="请选择"
+                id="gift-card-enable-state"></v-select>
             </a-form-item>
           </a-col>
           <a-col :md="6" :sm="24">
             <a-form-item label="充值时间" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
               <a-range-picker
-                id="winRecord-time"
-                v-model="time"
+                id="gift-card-rechargeTime"
+                v-model="rechargeTime"
                 :format="dateFormat"
                 :placeholder="['开始时间','结束时间']"
                 :disabledDate="disabledDate"
-                @change="onChange" />
+                @change="onRechargeChange" />
             </a-form-item>
           </a-col>
           <a-col :md="6" :sm="24">
             <a-form-item label="充值用户" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
-              <a-input allowClear v-model="searchData.activeName" :maxLength="30" placeholder="请输入充值用户" id="gift-card-name" />
+              <a-input allowClear v-model="searchData.customPhone" :maxLength="30" placeholder="请输入充值用户" id="gift-card-customPhone" />
             </a-form-item>
           </a-col>
           <a-col :md="6" :sm="24">
             <a-form-item label="充值码" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
-              <a-input allowClear v-model="searchData.activeName" :maxLength="30" placeholder="请输入充值码" id="gift-card-name" />
+              <a-input allowClear v-model="searchData.sequence" :maxLength="30" placeholder="请输入充值码" id="gift-card-sequence" />
             </a-form-item>
           </a-col>
           <a-col :md="6" :sm="24">
@@ -75,16 +81,17 @@
       :columns="columns"
       :data="loadData"
       bordered>
+      <!-- 操作按钮 -->
       <span slot="action" slot-scope="text, record">
         <a-button id="gift-card-getCode" class="blue" type="link" @click="getCode(record)">获取充值码</a-button>
         <a-button id="gift-card-handleEdit" class="green" type="link" @click="handleEdit(record)">编辑</a-button>
-        <a-button id="gift-card-handleDel" class="red" type="link" @click="handleDel(record)">删除</a-button>
+        <a-button v-if="record.state==0" id="gift-card-handleDel" class="red" type="link" @click="handleDel(record)">删除</a-button>
       </span>
     </s-table>
     <!-- 新增礼品卡 -->
-    <add-card-modal :openModal="openAddCardModal" @close="closeModal" />
+    <add-card-modal :openModal="openAddCardModal" @close="closeModal" @refresh="refreshFun" />
     <!-- 编辑礼品卡 -->
-    <edit-card-modal :openModal="openEditCardModal" :cardId="cardId" @close="closeModal" />
+    <edit-card-modal :openModal="openEditCardModal" :cardId="cardId" @refresh="refreshFun" @close="closeModal" />
     <!-- 获取充值码 -->
     <get-code-modal :openModal="openGetCodeModal" :cardId="cardId" @close="closeModal" />
   </a-card>
@@ -95,7 +102,7 @@ import { STable, VSelect } from '@/components'
 import AddCardModal from './addCardModal.vue'
 import EditCardModal from './editCardModal.vue'
 import GetCodeModal from './getCodeModal.vue'
-import { getLuckyDrawList } from '@/api/luckyDraw.js'
+import { giftCardQuery, giftCardDel } from '@/api/giftCard.js'
 
 export default {
   components: { STable, VSelect, GetCodeModal, AddCardModal, EditCardModal },
@@ -106,29 +113,37 @@ export default {
         wrapperCol: { span: 15 }
       },
       searchData: {
-        beginDate: null,
-        endDate: null,
-        activeName: '',
-        state: undefined
+        startTime: null, //  创建时间  开始
+        endTime: null, //  创建时间  结束
+        goldNum: null, //  礼品卡内容
+        optionalSequence: null, //  实体卡编号
+        state: undefined, //  是否已充值
+        useTimeStart: null, //  充值时间  开始
+        useTimeEnd: null, //  充值时间  结束
+        customPhone: null, //  充值用户
+        sequence: null //  充值码
       },
       showEditModal: false, // 默认关闭弹窗
       itemId: null, // 编辑行id
-      time: [],
+      time: [], //  创建时间
+      rechargeTime: [], //  充值时间
       dateFormat: 'YYYY-MM-DD',
       // 表头
       columns: [
         { title: '序号', dataIndex: 'no', width: 60, align: 'center' },
         { title: '创建时间', dataIndex: 'createDate', width: 100, align: 'center' },
-        { title: '活动名称', dataIndex: 'activeName', width: 100, align: 'center' },
-        { title: '活动时间', dataIndex: 'actime', width: 100, align: 'center' },
-        { title: '状态', dataIndex: 'state', width: 100, align: 'center' },
+        { title: '创建人', dataIndex: 'name', width: 100, align: 'center' },
+        { title: '礼品卡内容', dataIndex: 'content', width: 100, align: 'center' },
+        { title: '实体卡编号', dataIndex: 'optionalSequence', width: 100, align: 'center', customRender: (text) => { return text || '--' } },
+        { title: '是否已充值', dataIndex: 'stateDictValue', width: 100, align: 'center' },
+        { title: '充值时间', dataIndex: 'useTime', width: 100, align: 'center', customRender: (text) => { return text || '--' } },
+        { title: '充值用户', dataIndex: 'customPhone', width: 100, align: 'center', customRender: (text) => { return text || '--' } },
+        { title: '备注', dataIndex: 'remarks', width: 100, align: 'center', customRender: (text) => { return text || '--' } },
         { title: '操作', scopedSlots: { customRender: 'action' }, align: 'center', width: 100 }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
-        return getLuckyDrawList(
-          Object.assign(parameter, this.searchData)
-        ).then(res => {
+        return giftCardQuery(Object.assign(parameter, this.searchData)).then(res => {
           const no = (res.data.pageNo - 1) * res.data.pageSize
           if (res.status == 200) {
             for (let i = 0; i < res.data.list.length; i++) {
@@ -153,8 +168,15 @@ export default {
     // 创建时间change
     onChange (dates, dateStrings) {
       if ((dates, dateStrings)) {
-        this.searchData.beginDate = dateStrings[0]
-        this.searchData.endDate = dateStrings[1]
+        this.searchData.startTime = dateStrings[0]
+        this.searchData.endTime = dateStrings[1]
+      }
+    },
+    // 充值时间change
+    onRechargeChange (dates, dateStrings) {
+      if ((dates, dateStrings)) {
+        this.searchData.useTimeStart = dateStrings[0]
+        this.searchData.useTimeEnd = dateStrings[1]
       }
     },
     //  获取充值码
@@ -179,6 +201,11 @@ export default {
       this.openEditCardModal = false
       this.openGetCodeModal = false
     },
+    //  刷新数据
+    refreshFun (state) {
+      //  新增需刷新第一页数据。编辑为当前页数据
+      this.$refs.table.refresh(state)
+    },
     // 删除
     handleDel (record) {
       this.$confirm({
@@ -188,21 +215,26 @@ export default {
         okText: '确定',
         cancelText: '取消',
         onOk: () => {
-          // deleteLuckyDraw({
-          //   id: record.id
-          // }).then(res => {
-          //   if (res.status == 200) {
-          //     this.$message.success(res.message)
-          //     this.$refs.table.refresh()
-          //   }
-          // })
+          giftCardDel({ id: record.id }).then(res => {
+            if (res.status == 200) {
+              this.$message.success(res.message)
+              this.$refs.table.refresh()
+            }
+          })
         }
       })
     },
     // 重置
     resetForm () {
-      this.searchData.activeName = ''
-      this.searchData.state = ''
+      this.searchData.startTime = null
+      this.searchData.endTime = null
+      this.searchData.goldNum = null
+      this.searchData.optionalSequence = null
+      this.searchData.state = null
+      this.searchData.useTimeStart = null
+      this.searchData.useTimeEnd = null
+      this.searchData.customPhone = null
+      this.searchData.sequence = null
       this.$refs.table.refresh(true)
     }
   }