detailModal.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <a-modal
  3. centered
  4. class="promotion-basicInfo-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="详情"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. width="70%">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <div class="detailModal-con">
  13. <a-form-model
  14. id="promotion-basicInfo-form"
  15. ref="ruleForm"
  16. :model="form"
  17. :rules="rules"
  18. :label-col="formItemLayout.labelCol"
  19. :wrapper-col="formItemLayout.wrapperCol" >
  20. <a-row>
  21. <a-col :xs="12" :sm="12">
  22. <a-form-model-item label="促销名称" prop="promoName" :label-col="{span:8}" :wrapper-col="{span:14}">
  23. {{ form.promoName }}
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :xs="12" :sm="12">
  27. <a-form-model-item label="促销时间" prop="promoName" :label-col="{span:8}" :wrapper-col="{span:14}">
  28. {{ form.promoStartDate }}~{{ form.promoEndDate }}
  29. </a-form-model-item>
  30. </a-col>
  31. <a-col :xs="12" :sm="12">
  32. <a-form-model-item label="排序" prop="sort" :label-col="{span:8}" :wrapper-col="{span:14}">
  33. {{ form.sort||form.sort==0?form.sort:'--' }}
  34. </a-form-model-item>
  35. </a-col>
  36. <!-- <a-col :xs="12" :sm="12">
  37. <a-form-model-item label="参与经销商" prop="allDealerFlag" :label-col="{span:8}" :wrapper-col="{span:14}">
  38. {{ form.allDealerFlag=='1'?'全部经销商':'部分经销商' }}
  39. </a-form-model-item>
  40. </a-col> -->
  41. <a-col :xs="24" :sm="24">
  42. <a-form-model-item label="封面图片" prop="imageUrl">
  43. <img
  44. :src="form.imageUrl"
  45. alt="图片走丢了"
  46. width="80"
  47. height="80"
  48. style="margin-right:10px;object-fit: cover;"/>
  49. <div class="upload-desc">说明:单张大小小于10Mb;建议尺寸:宽(420px)*高(230px)</div>
  50. </a-form-model-item>
  51. </a-col>
  52. <a-col :xs="24" :sm="24">
  53. <a-form-model-item label="促销描述" prop="description" >
  54. {{ form.description||'--' }}
  55. </a-form-model-item>
  56. </a-col>
  57. <!-- <a-col :xs="24" :sm="24">
  58. <a-form-model-item label="加盟商开关权限:" prop="dealerOpenFlag" >
  59. {{ form.dealerOpenFlag?form.dealerOpenFlag==='1'?'是':'否':'--' }}
  60. </a-form-model-item>
  61. </a-col> -->
  62. <div v-if="form.promoType==='BUY_PROD_GIVE_VALID'">
  63. <a-col :xs="12" :sm="12">
  64. <a-form-model-item label="券名称" prop="validName" :label-col="{span:8}" :wrapper-col="{span:14}">
  65. {{ form.validName }}
  66. </a-form-model-item>
  67. </a-col>
  68. <a-col :xs="12" :sm="12">
  69. <a-form-model-item label="券副标题" :label-col="{span:8}" :wrapper-col="{span:14}">
  70. {{ form.validTitle ||'--' }}
  71. </a-form-model-item>
  72. </a-col>
  73. <!-- <a-col :xs="24" :sm="24">
  74. <a-form-model-item label="生成方式" prop="validBaseType">
  75. {{ form.validBaseTypeDictValue||'--' }}
  76. </a-form-model-item>
  77. </a-col> -->
  78. <a-col :xs="24" :sm="24">
  79. <a-form-model-item label="券有效期" prop="validType">
  80. <span>{{ form.validType==='FIXED'?'固定日期':'领取后,立即生效' }}</span>
  81. <span style="margin-left:10px;" v-if="form.validType==='FIXED'">{{ form.validStartDate }}~{{ form.validEndDate }}</span>
  82. <span style="margin-left:10px;" v-else>有效期{{ form.validDays }}天</span>
  83. </a-form-model-item>
  84. </a-col>
  85. <a-col :xs="24" :sm="24">
  86. <a-form-model-item label="券适用范围" prop="validScope">
  87. {{ form.validScope=='1'?'全部产品':'--' }}
  88. </a-form-model-item>
  89. </a-col>
  90. <a-col :xs="24" :sm="24">
  91. <a-form-model-item label="使用说明">
  92. {{ form.validInfo||'--' }}
  93. </a-form-model-item>
  94. </a-col>
  95. </div>
  96. <a-col :xs="24" :sm="24">
  97. <a-form-model-item :label="form.promoType==='BUY_PROD_GIVE_PROD'?'满赠规则': form.promoType==='PROMO_PROD'?'优惠方式':'返券产品'" prop="promoName" >
  98. <div class="productTable">
  99. <s-table
  100. class="sTable"
  101. ref="table"
  102. size="small"
  103. :rowKey="(record) => record.id"
  104. :columns="columns"
  105. :data="loadData"
  106. :defaultLoadData="false"
  107. :style="{ maxHeight: 300+'px' }"
  108. :scroll="{ y:230 }"
  109. bordered>
  110. </s-table>
  111. </div>
  112. </a-form-model-item>
  113. </a-col>
  114. </a-row>
  115. </a-form-model>
  116. <div class="btn-cont">
  117. <a-button id="promotion-basicInfo-modal-close" @click="isShow = false">关闭</a-button>
  118. </div>
  119. </div>
  120. </a-spin>
  121. </a-modal>
  122. </template>
  123. <script>
  124. import { commonMixin } from '@/utils/mixin'
  125. // 组件
  126. import { STable } from '@/components'
  127. // 接口
  128. import { shopPromoDetail, shopPromoProductList } from '@/api/shopPromo'
  129. export default {
  130. name: 'DetailModal',
  131. mixins: [commonMixin],
  132. components: { STable },
  133. props: {
  134. openModal: { // 弹框显示状态
  135. type: Boolean,
  136. default: false
  137. },
  138. itemSn: {// 活动sn
  139. type: String,
  140. default: ''
  141. }
  142. },
  143. data () {
  144. return {
  145. isShow: this.openModal, // 是否打开弹框
  146. spinning: false,
  147. // form表单label布局
  148. formItemLayout: {
  149. labelCol: { span: 4 },
  150. wrapperCol: { span: 18 }
  151. },
  152. productTypeList: [], // 产品范围数据
  153. productRangeList: [], // 已选产品范围
  154. form: {
  155. promoType: undefined, // 促销类型
  156. promoName: '', // '促销名称'
  157. time: [], // 促销时间
  158. promoStartDate: undefined, // 促销时间-开始
  159. promoEndDate: undefined, // 促销时间-结束
  160. sort: undefined, // 排序
  161. allDealerFlag: '1', // 全部经销商 1 部分经销商0'
  162. imageUrl: undefined, // 促销封面图
  163. description: '', // '促销描述'
  164. dealerEditFlag: '0', // 加盟商编辑 0否 1是
  165. dealerOpenFlag: '0', // 加盟商开关权限 0否 1是
  166. rangeList: [], // 选择产品列表
  167. discountType: 'STRAIGHT_DOWN', // 特价产品 - 优惠方式'
  168. validName: '', // 券名称
  169. validTitle: '', // 券副标题
  170. validBaseType: undefined, // 券生成方式
  171. validType: undefined, // 券有效期类型
  172. validStartDate: undefined, // 券生效时间
  173. validEndDate: undefined, // 券失效时间
  174. validDays: undefined, // 券有效期天数
  175. validScope: '1', // 券适用范围标记 1-全部 0-指定 死值 1
  176. validInfo: '' // 使用说明
  177. },
  178. // 表单验证规则
  179. rules: {
  180. promoName: [{ required: true, message: '请输入促销名称', trigger: 'blur' }],
  181. time: [{ required: true, message: '请选择促销时间', trigger: 'change' }],
  182. sort: [{ required: true, message: '请输入排序数字', trigger: 'blur' }],
  183. allDealerFlag: [{ required: true, message: '请选择参与经销商', trigger: 'change' }],
  184. imageUrl: [{ required: true, message: '请选择要上传的封面图片', trigger: 'change' }],
  185. description: [{ required: true, message: '请输入促销描述内容', trigger: 'blur' }],
  186. dealerOpenFlag: [{ required: true, message: '请选择加盟商开关权限', trigger: 'change' }],
  187. rangeList: [{ required: true, message: '请选择促销产品', trigger: 'change' }],
  188. validName: [{ required: true, message: '请输入券名称', trigger: ['change', 'blur'] }],
  189. validBaseType: [{ required: true, message: '请选择生成方式', trigger: 'change' }],
  190. validType: [{ required: true, message: '请选择券有效期类型', trigger: 'change' }],
  191. validScope: [{ required: true, message: '请选择券适用范围', trigger: 'blur' }]
  192. },
  193. // 加载数据方法 必须为 Promise 对象
  194. loadData: parameter => {
  195. this.disabled = true
  196. this.spinning = true
  197. const params = Object.assign(parameter, this.queryParam)
  198. params.promoSn = this.itemSn
  199. // 获取详情 已选参与活动产品数据
  200. return shopPromoProductList(params).then(res => {
  201. let data
  202. if (res.status == 200) {
  203. data = res.data
  204. // 计算表格序号
  205. const no = (data.pageNo - 1) * data.pageSize
  206. for (var i = 0; i < data.list.length; i++) {
  207. data.list[i].no = no + i + 1
  208. }
  209. this.disabled = false
  210. }
  211. this.spinning = false
  212. return data
  213. })
  214. }
  215. }
  216. },
  217. computed: {
  218. columns () {
  219. const _this = this
  220. const arr = [
  221. { title: '序号', dataIndex: 'no', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  222. { title: '产品编码', dataIndex: 'productCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  223. { title: '产品名称', dataIndex: 'productName', width: '28%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  224. { title: '原厂编码', dataIndex: 'productOrigCode', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  225. { title: '商城售价', dataIndex: 'shopProductPrice', width: '10%', align: 'right', customRender: text => { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  226. ]
  227. if (_this.form.promoType === 'BUY_PROD_GIVE_PROD') {
  228. arr.splice(4, 0, { title: '买', dataIndex: 'conditionValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } })
  229. arr.splice(5, 0, { title: '赠', dataIndex: 'resultValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } })
  230. } else if (_this.form.promoType === 'PROMO_PROD') {
  231. arr.splice(5, 0, { title: '特价价格', dataIndex: 'conditionValue', width: '10%', align: 'right', customRender: text => { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  232. } else {
  233. arr.splice(5, 0, { title: '返券金额', dataIndex: 'resultValue', width: '10%', align: 'center', customRender: text => { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  234. }
  235. return arr
  236. }
  237. },
  238. methods: {
  239. // 重置
  240. resetSearchForm () {
  241. this.form = {
  242. promoType: undefined, // 促销类型
  243. promoName: '', // '促销名称'
  244. time: [], // 促销时间
  245. promoStartDate: undefined, // 促销时间-开始
  246. promoEndDate: undefined, // 促销时间-结束
  247. sort: undefined, // 排序
  248. allDealerFlag: '1', // 全部经销商 1 部分经销商0'
  249. imageUrl: undefined, // 促销封面图
  250. description: '', // '促销描述'
  251. dealerEditFlag: '0', // 加盟商编辑 0否 1是
  252. dealerOpenFlag: '0', // 加盟商开关权限 0否 1是
  253. rangeList: [], // 选择产品列表
  254. discountType: 'STRAIGHT_DOWN', // 特价产品 - 优惠方式'
  255. validName: '', // 券名称
  256. validTitle: '', // 券副标题
  257. validBaseType: undefined, // 券生成方式
  258. validType: undefined, // 券有效期类型
  259. validStartDate: undefined, // 券生效时间
  260. validEndDate: undefined, // 券失效时间
  261. validDays: undefined, // 券有效期天数
  262. validScope: '1', // 券适用范围标记 1-全部 0-指定 死值 1
  263. validInfo: '' // 使用说明
  264. }
  265. },
  266. // 获取列表详情
  267. getDetail () {
  268. shopPromoDetail({ sn: this.itemSn }).then(res => {
  269. if (res.status == 200) {
  270. this.form = res.data
  271. this.$nextTick(() => {
  272. this.$refs.table.refresh(true)
  273. })
  274. }
  275. })
  276. }
  277. },
  278. watch: {
  279. // 父页面传过来的弹框状态
  280. openModal (newValue, oldValue) {
  281. this.isShow = newValue
  282. },
  283. // 重定义的弹框状态
  284. isShow (newValue, oldValue) {
  285. if (!newValue) {
  286. this.$emit('close')
  287. this.resetSearchForm()
  288. } else {
  289. this.getDetail()
  290. }
  291. }
  292. }
  293. }
  294. </script>
  295. <style lang="less" scoped>
  296. .promotion-basicInfo-modal{
  297. .detailModal-con{
  298. max-height: 600px;
  299. overflow-y: scroll;
  300. }
  301. .timeBox{
  302. color:#ed1c24;
  303. opacity: .7;
  304. }
  305. .ant-modal-body {
  306. padding: 40px 40px 24px;
  307. }
  308. .promotion-basicInfo-con{
  309. margin-top:10px;
  310. }
  311. .ant-form-item{
  312. margin-bottom:0 !important;
  313. }
  314. .buyerBox{
  315. border:1px solid #d9d9d9;margin-top:10px;border-radius:4px;padding:4px 10px;background:#f2f2f2;max-height:130px;overflow-y:scroll;
  316. }
  317. .btn-cont {
  318. text-align: center;
  319. margin: 35px 0 10px;
  320. }
  321. //处理滚动条不显示
  322. .tabBox{
  323. max-height:100px;
  324. overflow-y:scroll;
  325. }
  326. .tabBox::-webkit-scrollbar {
  327. width: 0px;
  328. }
  329. .tabBox::-webkit-scrollbar-track {
  330. background: transparent;
  331. }
  332. .tabBox::-webkit-scrollbar-thumb {
  333. background: transparent;
  334. }
  335. .tabBox::-webkit-scrollbar-button {
  336. display: none;
  337. }
  338. // 设置input 禁用颜色
  339. .ant-form-item-control .ant-input[disabled]{
  340. color:#333333;
  341. background:#ffffff;
  342. }
  343. .ant-radio-button-wrapper-disabled{
  344. color:#333333;
  345. padding:0 16px;
  346. }
  347. .ant-radio-button-wrapper-disabled.ant-radio-button-wrapper-checked{
  348. background-color: #ed1c24 !important;
  349. color:#ffffff;
  350. padding:0 16px;
  351. }
  352. /deep/.ant-select-disabled .ant-select-selection, .ant-cascader-picker-disabled{
  353. color:#333 !important;
  354. background:#fff;
  355. }
  356. .productTable{
  357. width:100%;
  358. }
  359. /deep/.ant-select-disabled .ant-select-selection--multiple .ant-select-selection__choice{
  360. color:#333;
  361. }
  362. }
  363. </style>