|
@@ -0,0 +1,599 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <el-form
|
|
|
+ ref="form"
|
|
|
+ :rules="rules"
|
|
|
+ :model="form"
|
|
|
+ label-position="left"
|
|
|
+ label-width="100px"
|
|
|
+ >
|
|
|
+ <el-form-item label="注解名称" class="is-required" prop="name">
|
|
|
+ <el-input
|
|
|
+ v-model="form.name"
|
|
|
+ type="text"
|
|
|
+ :disabled="disable"
|
|
|
+ style="width: 300px"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="备注" class="is-required" prop="remark">
|
|
|
+ <el-input
|
|
|
+ v-model="form.remark"
|
|
|
+ type="textarea"
|
|
|
+ :disabled="disable"
|
|
|
+ style="width: 300px"
|
|
|
+ autocomplete="off"
|
|
|
+ maxlength="500"
|
|
|
+ show-word-limit
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="应用" class="is-required" prop="remark">
|
|
|
+ <el-select
|
|
|
+ v-model="form.addStock"
|
|
|
+ clearable
|
|
|
+ filterable
|
|
|
+ value-key="value"
|
|
|
+ style="width: 300px; margin-right: 20px"
|
|
|
+ placeholder=""
|
|
|
+ class="filter-item"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in typeOption"
|
|
|
+ :key="index"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <div v-if="$route.query.editType === '1'">
|
|
|
+ <el-button type="primary" :hidden="disable" @click="updateData('form')">
|
|
|
+ 保存
|
|
|
+ </el-button>
|
|
|
+ <el-button @click="resetUpdateForm('form')">重置</el-button>
|
|
|
+ <el-button @click="closePage()">关闭</el-button>
|
|
|
+ </div>
|
|
|
+ <div v-else>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ :hidden="disable"
|
|
|
+ @click="saveEditData('form')"
|
|
|
+ >
|
|
|
+ 保存
|
|
|
+ </el-button>
|
|
|
+ <el-button @click="resetForm('form')">重置</el-button>
|
|
|
+ <el-button @click="closePage()">关闭</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import {
|
|
|
+ getCouponList,
|
|
|
+ getCouponPageList,
|
|
|
+ getEventInfo,
|
|
|
+ getSourceListApi,
|
|
|
+ saveEventInfo,
|
|
|
+ updateEventInfo,
|
|
|
+ uploadPic,
|
|
|
+ } from '../../axios/api'
|
|
|
+ import * as CouponPageListVo from '../../axios/vo/coupon-list-vo.js'
|
|
|
+ import { Message } from 'element-ui'
|
|
|
+ import { activity } from '@/api'
|
|
|
+
|
|
|
+ const toolbarOptions = [
|
|
|
+ ['bold', 'italic', 'underline', 'strike'], // toggled buttons
|
|
|
+ ['blockquote', 'code-block'],
|
|
|
+
|
|
|
+ [{ header: 1 }, { header: 2 }], // custom button values
|
|
|
+ [{ list: 'ordered' }, { list: 'bullet' }],
|
|
|
+ [{ script: 'sub' }, { script: 'super' }], // superscript/subscript
|
|
|
+ [{ indent: '-1' }, { indent: '+1' }], // outdent/indent
|
|
|
+ [{ direction: 'rtl' }], // text direction
|
|
|
+
|
|
|
+ [{ size: ['small', false, 'large', 'huge'] }], // custom dropdown
|
|
|
+ [{ header: [1, 2, 3, 4, 5, 6, false] }],
|
|
|
+
|
|
|
+ [{ color: [] }, { background: [] }], // dropdown with defaults from theme
|
|
|
+ [{ font: [] }],
|
|
|
+ [{ align: [] }],
|
|
|
+ ['link', 'image'],
|
|
|
+ ['clean'], // remove formatting button
|
|
|
+ ]
|
|
|
+ export default {
|
|
|
+ name: 'UserInfoList',
|
|
|
+ components: {},
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ editorOption: {
|
|
|
+ placeholder: '',
|
|
|
+ theme: 'snow', // or 'bubble'
|
|
|
+ modules: {
|
|
|
+ toolbar: {
|
|
|
+ container: toolbarOptions, // 工具栏
|
|
|
+ handlers: {
|
|
|
+ image: function (value) {
|
|
|
+ if (value) {
|
|
|
+ document.querySelector('#quill-upload input').click()
|
|
|
+ } else {
|
|
|
+ this.quill.format('image', false)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+
|
|
|
+ quillUpdateImg: false, // 根据图片上传状态来确定是否显示loading动画,刚开始是false,不显示
|
|
|
+
|
|
|
+ activityId: null,
|
|
|
+ listLoading: true,
|
|
|
+ dialogFormVisibleChoose: false,
|
|
|
+ disable: false,
|
|
|
+ timestamp: '',
|
|
|
+ useLimitType: 0,
|
|
|
+ costLimitType: 0,
|
|
|
+ showCoverImg: '',
|
|
|
+ couponList: [],
|
|
|
+
|
|
|
+ optionsMerchant: [
|
|
|
+ {
|
|
|
+ merchantId: '1605064954',
|
|
|
+ merchantName: '厐睿',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ merchantId: '1609190004',
|
|
|
+ merchantName: '庞嘉',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ typeSource: [],
|
|
|
+
|
|
|
+ form: {
|
|
|
+ showPrice: 1,
|
|
|
+ name: '',
|
|
|
+ balanceMchid: '',
|
|
|
+ coverImg: '',
|
|
|
+ stock: '',
|
|
|
+ getLimit: '',
|
|
|
+ timestamp: '',
|
|
|
+ beginTimestamp: '',
|
|
|
+ endTimestamp: '',
|
|
|
+ isPay: 0,
|
|
|
+ isForever: 0,
|
|
|
+ price: 1,
|
|
|
+ remark: '',
|
|
|
+ buyRemark: '',
|
|
|
+ refundType: 1,
|
|
|
+ status: 1,
|
|
|
+ script: 0,
|
|
|
+ supplement: 0,
|
|
|
+ couponIdList: [
|
|
|
+ {
|
|
|
+ couponId: '',
|
|
|
+ num: '1',
|
|
|
+ price: '1',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+
|
|
|
+ payMainType: 1,
|
|
|
+ merchantId: '',
|
|
|
+ source: '',
|
|
|
+ },
|
|
|
+ typeOption: [
|
|
|
+ {
|
|
|
+ value: '1',
|
|
|
+ label: '卡券',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: '2',
|
|
|
+ label: '招商',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ rules: {
|
|
|
+ name: [
|
|
|
+ { required: true, message: '请输入活动名称', trigger: 'blur' },
|
|
|
+ {
|
|
|
+ min: 1,
|
|
|
+ max: 80,
|
|
|
+ message: '长度在 1 到 80 个字符',
|
|
|
+ trigger: 'blur',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ remark: [
|
|
|
+ { required: true, message: '请输入活动备注', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async created() {
|
|
|
+ ;(this.form = {
|
|
|
+ showPrice: 1,
|
|
|
+ name: '',
|
|
|
+ coverImg: '',
|
|
|
+ stock: '',
|
|
|
+ getLimit: '',
|
|
|
+ timestamp: '',
|
|
|
+ beginTimestamp: '',
|
|
|
+ endTimestamp: '',
|
|
|
+ isPay: 0,
|
|
|
+ isForever: 0,
|
|
|
+ price: 1,
|
|
|
+ remark: '',
|
|
|
+ status: 1,
|
|
|
+ refundType: 1,
|
|
|
+ script: 0,
|
|
|
+ supplement: 0,
|
|
|
+ couponIdList: [
|
|
|
+ {
|
|
|
+ couponId: '',
|
|
|
+ num: '1',
|
|
|
+ price: '1',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+
|
|
|
+ payMainType: 1,
|
|
|
+ merchantId: '',
|
|
|
+ }),
|
|
|
+ this.loadCouponList()
|
|
|
+ let copyActivityId = this.$route.query.copyActivityId
|
|
|
+
|
|
|
+ if (copyActivityId) {
|
|
|
+ let copyActivity = await activity.getDetail(copyActivityId)
|
|
|
+ let editType = this.$route.query.editType
|
|
|
+ if (editType && editType === '1') {
|
|
|
+ console.log(editType)
|
|
|
+ this.dealUpdateAct(copyActivity)
|
|
|
+ } else {
|
|
|
+ console.log(123)
|
|
|
+ this.dealCopyActivity(copyActivity)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.geSourceList()
|
|
|
+ },
|
|
|
+
|
|
|
+ methods: {
|
|
|
+ geSourceList() {
|
|
|
+ const data = {
|
|
|
+ page: 1,
|
|
|
+ pageSize: 1000,
|
|
|
+ }
|
|
|
+ getSourceListApi(data)
|
|
|
+ .then((res) => {
|
|
|
+ let result = res.data.data
|
|
|
+ console.log(result)
|
|
|
+ let sourceList = result.list
|
|
|
+ let typeSource = []
|
|
|
+
|
|
|
+ for (let i in sourceList) {
|
|
|
+ typeSource.push({
|
|
|
+ value: sourceList[i]['sourceValue'],
|
|
|
+ label: sourceList[i]['sourceValue'],
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.typeSource = typeSource
|
|
|
+ console.log(this.typeSource)
|
|
|
+ })
|
|
|
+ .catch((err) => Message.error(err))
|
|
|
+ },
|
|
|
+ uploadQuillImg(file) {
|
|
|
+ let formData = new window.FormData()
|
|
|
+ formData.append('file', file.raw)
|
|
|
+ formData.append('isPublic', 'true')
|
|
|
+ this.quillUpdateImg = true
|
|
|
+ uploadPic(formData)
|
|
|
+ .then((res) => {
|
|
|
+ this.quillUpdateImg = false
|
|
|
+ if (res.data.code != 200) {
|
|
|
+ Message.error(res.data.msg)
|
|
|
+ } else {
|
|
|
+ Message.success('上传成功')
|
|
|
+ this.uploadSuccess(res.data.data.destPath)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err) => Message.error(err))
|
|
|
+ },
|
|
|
+
|
|
|
+ // 上传图片成功
|
|
|
+ uploadSuccess(res) {
|
|
|
+ // res为图片服务器返回的数据
|
|
|
+ // 获取富文本组件实例
|
|
|
+ let quill = this.$refs.myQuillEditor.quill
|
|
|
+ // 获取光标所在位置
|
|
|
+ let length = quill.getSelection().index
|
|
|
+ // 插入图片 res.info为服务器返回的图片地址
|
|
|
+ quill.insertEmbed(length, 'image', res)
|
|
|
+ // 调整光标到最后
|
|
|
+ quill.setSelection(length + 1)
|
|
|
+ },
|
|
|
+
|
|
|
+ loadCouponList() {
|
|
|
+ let pageQuery = new CouponPageListVo.CouponPageListVo()
|
|
|
+ let condition = new CouponPageListVo.Condition()
|
|
|
+ condition.state = { value: '2', text: '' }
|
|
|
+
|
|
|
+ pageQuery.condition = condition
|
|
|
+ // 以后优化
|
|
|
+ pageQuery.pageSize = 1000
|
|
|
+ getCouponPageList(pageQuery)
|
|
|
+ .then((res) => {
|
|
|
+ this.couponList = res.data.data.list
|
|
|
+ })
|
|
|
+ .catch((err) => Message.error(err))
|
|
|
+ },
|
|
|
+ resetForm(formName) {
|
|
|
+ this.$refs[formName].resetFields()
|
|
|
+ },
|
|
|
+ resetUpdateForm() {
|
|
|
+ ;(this.form.name = ''),
|
|
|
+ (this.form.coverImg = ''),
|
|
|
+ (this.form.remark = ''),
|
|
|
+ (this.form.buyRemark = '')
|
|
|
+ },
|
|
|
+ saveEditData(formName) {
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ var couponIdList = this.form.couponIdList
|
|
|
+
|
|
|
+ var obj = {}
|
|
|
+ var numIsEmpty = false
|
|
|
+ var mustPrice = false
|
|
|
+ var couponTotalPrice = 0
|
|
|
+ for (var i in couponIdList) {
|
|
|
+ console.log(couponIdList[i].couponId)
|
|
|
+ obj[couponIdList[i].couponId] = couponIdList[i].couponId
|
|
|
+ if (!couponIdList[i].num) {
|
|
|
+ numIsEmpty = true
|
|
|
+ }
|
|
|
+ if (!couponIdList[i].price) {
|
|
|
+ mustPrice = true
|
|
|
+ } else {
|
|
|
+ couponTotalPrice += couponIdList[i].price * 100
|
|
|
+ }
|
|
|
+ }
|
|
|
+ couponTotalPrice = couponTotalPrice / 100
|
|
|
+
|
|
|
+ console.log(couponTotalPrice)
|
|
|
+ console.log(this.form.price)
|
|
|
+ if (numIsEmpty) {
|
|
|
+ this.$message({
|
|
|
+ message: '券的数量必须要填写',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (mustPrice && this.form.isPay == 1) {
|
|
|
+ this.$message({
|
|
|
+ message: '付费活动中券的价格需要填写',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Object.keys(obj).length != couponIdList.length) {
|
|
|
+ this.$message({
|
|
|
+ message: '选择的券不能重复',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!this.form.price && this.form.isPay == 1) {
|
|
|
+ this.$message({
|
|
|
+ message: '付费活动需要设置活动金额',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.form.isPay == 1 && this.form.price != couponTotalPrice) {
|
|
|
+ this.$message({
|
|
|
+ message: '券的总价格和活动金额不相等',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!this.form.merchantId && this.form.isPay == 1) {
|
|
|
+ this.$message({
|
|
|
+ message: '付费活动需要设置默认商户号',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.saveEditData1()
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ saveEditData1: function () {
|
|
|
+ let coupon = JSON.parse(JSON.stringify(this.form))
|
|
|
+ // copy数据
|
|
|
+ // 格式化时间条件
|
|
|
+ // 把数字解析成时间格式
|
|
|
+
|
|
|
+ coupon.price = (this.form.price * 100).toFixed(0)
|
|
|
+ coupon.showPrice = (this.form.showPrice * 100).toFixed(0)
|
|
|
+ for (var i in coupon.couponIdList) {
|
|
|
+ coupon.couponIdList[i].price = (
|
|
|
+ coupon.couponIdList[i].price * 100
|
|
|
+ ).toFixed(0)
|
|
|
+ }
|
|
|
+ coupon.beginTimestamp = this.form.timestamp[0]
|
|
|
+ coupon.endTimestamp = this.form.timestamp[1]
|
|
|
+ console.log(coupon)
|
|
|
+
|
|
|
+ saveEventInfo(coupon)
|
|
|
+ .then((res) => {
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ Message.success('保存成功')
|
|
|
+ this.closePage()
|
|
|
+ } else {
|
|
|
+ Message.error(res.data.msg)
|
|
|
+ }
|
|
|
+ // this.loadData()
|
|
|
+ })
|
|
|
+ .catch((err) => Message.error(err))
|
|
|
+ },
|
|
|
+ updateData(formName) {
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.updateData1()
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ updateData1: function () {
|
|
|
+ let coupon = JSON.parse(JSON.stringify(this.form))
|
|
|
+ let data = {
|
|
|
+ activityId: this.$route.query.copyActivityId,
|
|
|
+ name: coupon.name,
|
|
|
+ coverImg: coupon.coverImg,
|
|
|
+ remark: coupon.remark,
|
|
|
+ buyRemark: coupon.buyRemark,
|
|
|
+ script: coupon.script,
|
|
|
+ supplement: coupon.supplement,
|
|
|
+ beginTimestamp: this.form.timestamp[0],
|
|
|
+ endTimestamp: this.form.timestamp[1],
|
|
|
+ }
|
|
|
+
|
|
|
+ updateEventInfo(data)
|
|
|
+ .then((res) => {
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ Message.success('修改成功')
|
|
|
+ this.closePage()
|
|
|
+ } else {
|
|
|
+ Message.error(res.data.msg)
|
|
|
+ }
|
|
|
+ // this.loadData()
|
|
|
+ })
|
|
|
+ .catch((err) => Message.error(err))
|
|
|
+ },
|
|
|
+ handleChange(file) {
|
|
|
+ let formData = new window.FormData()
|
|
|
+ formData.append('file', file.raw)
|
|
|
+ formData.append('isPublic', 'true')
|
|
|
+ uploadPic(formData)
|
|
|
+ .then((res) => {
|
|
|
+ if (res.data.code != 200) {
|
|
|
+ Message.error(res.data.msg)
|
|
|
+ } else {
|
|
|
+ Message.success('上传成功')
|
|
|
+ this.showCoverImg = res.data.data.destPath
|
|
|
+ this.form.coverImg = res.data.data.url
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err) => Message.error(err))
|
|
|
+ },
|
|
|
+ removeDomain(item) {
|
|
|
+ var index = this.form.couponIdList.indexOf(item)
|
|
|
+ if (index !== -1) {
|
|
|
+ this.form.couponIdList.splice(index, 1)
|
|
|
+ }
|
|
|
+ this.updateFormPrice()
|
|
|
+ },
|
|
|
+ addDomain() {
|
|
|
+ this.form.couponIdList.push({
|
|
|
+ couponId: '',
|
|
|
+ num: '1',
|
|
|
+ price: '1',
|
|
|
+ key: Date.now(),
|
|
|
+ })
|
|
|
+ this.updateFormPrice()
|
|
|
+ },
|
|
|
+ closePage() {
|
|
|
+ this.$router.go(-1)
|
|
|
+ },
|
|
|
+ updateFormPrice() {
|
|
|
+ let couponIdList = this.form.couponIdList
|
|
|
+ let total = 0
|
|
|
+ for (let i in couponIdList) {
|
|
|
+ let price = couponIdList[i]['price'] ? couponIdList[i]['price'] : 1
|
|
|
+ total += Number(price)
|
|
|
+ }
|
|
|
+ this.form.price = Number(total)
|
|
|
+ },
|
|
|
+
|
|
|
+ //处理修改的数据
|
|
|
+ dealUpdateAct(copyActivity) {
|
|
|
+ console.log(copyActivity)
|
|
|
+ this.showCoverImg = copyActivity.fullCoverImg
|
|
|
+ let date1 = new Date(copyActivity.beginTimestamp)
|
|
|
+ let beginTimestamp = date1.getTime()
|
|
|
+
|
|
|
+ let date2 = new Date(copyActivity.endTimestamp)
|
|
|
+ let endTimestamp = date2.getTime()
|
|
|
+ this.form = {
|
|
|
+ name: copyActivity.name,
|
|
|
+ coverImg: copyActivity.coverImg,
|
|
|
+ remark: copyActivity.remark,
|
|
|
+ buyRemark: copyActivity.buyRemark,
|
|
|
+ script: copyActivity.script || 0,
|
|
|
+ supplement: copyActivity.supplement || 0,
|
|
|
+ timestamp: [beginTimestamp, endTimestamp],
|
|
|
+ beginTimestamp: beginTimestamp,
|
|
|
+ endTimestamp: endTimestamp,
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 活动源改变活动类型
|
|
|
+ * @param e
|
|
|
+ */
|
|
|
+ changeFormSource(e) {
|
|
|
+ let _self = this
|
|
|
+ if (e == 'FREE_MINI_APP') {
|
|
|
+ _self.form.isPay = 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+</script>
|
|
|
+<style>
|
|
|
+ .active {
|
|
|
+ display: inline-block;
|
|
|
+ }
|
|
|
+ .timeActive {
|
|
|
+ display: block;
|
|
|
+ line-height: 50px;
|
|
|
+ }
|
|
|
+ .pTitle {
|
|
|
+ border-left: 3px solid #1890ff;
|
|
|
+ padding-left: 5px;
|
|
|
+ line-height: 25px;
|
|
|
+ font-size: 15px;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+ .coupon_num {
|
|
|
+ width: 100px;
|
|
|
+ margin-left: 10px;
|
|
|
+ margin-right: 20px;
|
|
|
+ }
|
|
|
+ .coupon_price {
|
|
|
+ width: 100px;
|
|
|
+ margin-left: 10px;
|
|
|
+ margin-right: 20px;
|
|
|
+ }
|
|
|
+ .coupon_name {
|
|
|
+ margin-left: 10px;
|
|
|
+ margin-right: 20px;
|
|
|
+ }
|
|
|
+ .coupon_p {
|
|
|
+ display: flex;
|
|
|
+ flex-flow: row nowrap;
|
|
|
+ justify-content: left;
|
|
|
+ align-items: center;
|
|
|
+ }
|
|
|
+ .ql-editor {
|
|
|
+ min-height: 360px;
|
|
|
+ }
|
|
|
+ .el-upload-list--text {
|
|
|
+ width: 300px;
|
|
|
+ }
|
|
|
+</style>
|