detail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <div class="promotionRulesDetail-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="promotionRulesDetail-back" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="promotionRulesDetail-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. </template>
  9. </a-page-header>
  10. <a-card size="small" :bordered="false" class="promotionRulesDetail-cont">
  11. <a-descriptions bordered :column="2" size="small" v-if="detailsData">
  12. <a-descriptions-item label="活动名称:">{{ detailsData.name || '--' }}</a-descriptions-item>
  13. <a-descriptions-item label="活动时间:">
  14. <span v-if="detailsData.activeDateEnable=='0'">不限</span>
  15. <span v-else>{{ detailsData.activeDateStart }} ~ {{ detailsData.activeDateEnd }}</span>
  16. </a-descriptions-item>
  17. <a-descriptions-item label="参与客户:">
  18. <span v-if="detailsData.buyerLimitEnable=='0'">全部客户</span>
  19. <p v-else style="margin: 0;">部分客户,共{{ detailsData.promoBuyerList.length }}<a-button id="promotionRules-rule-normalGoodsList" type="primary" size="small" class="button-success" @click="handleLook(detailsData.promoBuyerList)">查看</a-button></p>
  20. </a-descriptions-item>
  21. <a-descriptions-item label="活动经费上限:">
  22. <span v-if="detailsData.activeAmountEnable=='0'">不限</span>
  23. <span v-else>{{ detailsData.activeAmount }} 万元</span>
  24. </a-descriptions-item>
  25. <a-descriptions-item label="订单起订金额:">
  26. <span v-if="detailsData.orderAmountEnable=='0'">不限</span>
  27. <span v-else>{{ detailsData.orderAmount }} 万元</span>
  28. </a-descriptions-item>
  29. <a-descriptions-item label="备注:">{{ detailsData.remark || '--' }}</a-descriptions-item>
  30. </a-descriptions>
  31. <a-divider />
  32. <!-- 列表 -->
  33. <p style="font-weight: bold;">促销规则:</p>
  34. <a-table
  35. class="sTable"
  36. ref="table"
  37. size="small"
  38. :rowKey="(record) => record.id"
  39. :columns="columns"
  40. :data-source="promoRuleList"
  41. :scroll="{ y: tableHeight }"
  42. :loading="loading"
  43. :pagination="false"
  44. bordered>
  45. <!-- 操作 -->
  46. <template slot="action" slot-scope="text, record">
  47. <a-button
  48. v-if="record.promoRuleType!='PROMO_PROD'"
  49. size="small"
  50. type="link"
  51. class="button-info"
  52. @click="handleLookP(record.normalGoodsList, record.promoRuleType, 'normal')"
  53. id="promotionRulesDetail-edit-btn">查看正价品</a-button>
  54. <a-button
  55. size="small"
  56. type="link"
  57. class="button-warning"
  58. @click="handleLookP(record.promoGoodsList, record.promoRuleType, 'promo')"
  59. id="promotionRulesDetail-del-btn">查看{{ record.promoRuleType=='PROMO_PROD' ? '特价品' : record.promoRuleType=='ADD_PRICE_PURCH' ? '换购品' : '促销品' }}</a-button>
  60. </template>
  61. </a-table>
  62. </a-card>
  63. </a-spin>
  64. <!-- 查看客户/正价品/促销品 -->
  65. <a-modal
  66. centered
  67. class="promotionRulesDetail-look-modal"
  68. :footer="null"
  69. :maskClosable="false"
  70. title="查看"
  71. v-model="openModal"
  72. @cancle="openModal = false"
  73. width="80%">
  74. <a-table
  75. ref="lookTable"
  76. size="small"
  77. :rowKey="(record) => record.id"
  78. :columns="nowColumns"
  79. :data-source="lookLoadData"
  80. :pagination="false"
  81. :scroll="{ y: 500 }"
  82. bordered>
  83. <!-- 序号 -->
  84. <template slot="no" slot-scope="text, record, index">{{ index+1 }}</template>
  85. <!-- 起订量限制 -->
  86. <template slot="orderGoodsUnit" slot-scope="text, record">
  87. {{ record.orderGoodsUnit=='PROD_UNIT' ? '按设置数量':record.orderGoodsUnit=='FULL_BOX' ? '按整箱':'--' }}
  88. <span v-if="record.orderGoodsUnit=='PROD_UNIT'"> -- {{ record.orderGoodsQty }}</span>
  89. </template>
  90. <template slot="goodsPrice" slot-scope="text, record">
  91. <span>{{ (record.goodsPrice || record.goodsPrice==0) ? record.goodsPrice : '--' }}</span>
  92. </template>
  93. </a-table>
  94. </a-modal>
  95. </div>
  96. </template>
  97. <script>
  98. import { commonMixin } from '@/utils/mixin'
  99. import { promoActiveDetailD } from '@/api/promoActive'
  100. export default {
  101. name: 'PromotionRulesManagementDetail',
  102. mixins: [commonMixin],
  103. data () {
  104. return {
  105. spinning: false,
  106. tableHeight: 0,
  107. detailsData: null,
  108. columns: [
  109. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  110. { title: '创建时间', dataIndex: 'createDate', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  111. { title: '促销类型', dataIndex: 'promoRuleTypeDictValue', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
  112. { title: '促销规则', dataIndex: 'promoRule', align: 'center', width: '37%', customRender: function (text) { return text || '--' }, ellipsis: true },
  113. { title: '操作', scopedSlots: { customRender: 'action' }, width: '18%', align: 'center' }
  114. ],
  115. loadData: [],
  116. openModal: false,
  117. custColumns: [
  118. { title: '序号', scopedSlots: { customRender: 'no' }, width: '5%', align: 'center' },
  119. { title: '客户名称', dataIndex: 'buyerName', align: 'center', width: '95%', customRender: function (text) { return text || '--' } }
  120. ],
  121. pColumns: [ // 正品
  122. { title: '序号', scopedSlots: { customRender: 'no' }, width: '4%', align: 'center' },
  123. { title: '类型', dataIndex: 'goodsTypeName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  124. { title: '类型名称', dataIndex: 'goodsName', align: 'center', width: '25%', customRender: function (text) { return text || '--' }, ellipsis: true },
  125. { title: '产品名称', dataIndex: 'name', align: 'center', width: '25%', customRender: function (text) { return text || '--' }, ellipsis: true },
  126. { title: '产品编码', dataIndex: 'goodsCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  127. { title: '起订量限制', scopedSlots: { customRender: 'orderGoodsUnit' }, width: '14%', align: 'center' }
  128. ],
  129. promoColumns: [ // 促销品
  130. { title: '序号', scopedSlots: { customRender: 'no' }, width: '5%', align: 'center' },
  131. { title: '类型', dataIndex: 'goodsTypeName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  132. { title: '类型名称', dataIndex: 'goodsName', width: '35%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  133. { title: '产品名称', dataIndex: 'name', align: 'center', width: '35%', customRender: function (text) { return text || '--' }, ellipsis: true },
  134. { title: '产品编码', dataIndex: 'goodsCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
  135. ],
  136. promoSpecialColumns: [ // 特价产品/加价促销品
  137. { title: '序号', scopedSlots: { customRender: 'no' }, width: '5%', align: 'center' },
  138. { title: '产品名称', dataIndex: 'name', align: 'center', width: '50%', customRender: function (text) { return text || '--' }, ellipsis: true },
  139. { title: '产品编码', dataIndex: 'goodsCode', width: '30%', align: 'center', customRender: function (text) { return text || '--' } },
  140. { title: this.promoRuleType == 'PROMO_PROD' ? '特惠单价(¥)' : '换购单价(¥)', width: '15%', scopedSlots: { customRender: 'goodsPrice' }, width: 200, align: 'center' }
  141. ],
  142. lookLoadData: [],
  143. promoRuleList: [],
  144. nowColumns: [],
  145. promoRuleType: '', // 当前查看类型 买产品送产品...
  146. loading: false
  147. }
  148. },
  149. methods: {
  150. // 详情
  151. getDetail () {
  152. const _this = this
  153. this.spinning = true
  154. this.loading = true
  155. promoActiveDetailD({ sn: this.$route.params.sn }).then(res => {
  156. this.loading = false
  157. this.spinning = false
  158. if (res.status == 200) {
  159. _this.detailsData = res.data
  160. if (_this.detailsData.promoRuleList) {
  161. _this.detailsData.promoRuleList.map((item, index) => {
  162. item.no = index + 1
  163. if (item.promoRuleType == 'BUY_PROD_GIVE_PROD') { // 买产品送产品
  164. item.promoRule = '购买满' + item.orderGoodsQty + '个正价产品,送' + item.promoQty + '个促销品'
  165. } else if (item.promoRuleType == 'BUY_PROD_GIVE_MONEY') { // 买产品送采购额
  166. if (item.promoType == 'promo_amount') {
  167. item.promoRule = '购买满' + item.orderAmount + '元正价产品,送' + item.promoAmount + '元采购额可用于购买促销品'
  168. } else if (item.promoType == 'promo_amount_per') {
  169. item.promoRule = '购买满' + item.orderAmount + '元正价产品可以返正价产品采购额的' + item.promoAmountPer * 100 + '%用于购买促销品'
  170. }
  171. } else if (item.promoRuleType == 'ADD_PRICE_PURCH') { // 加价换购
  172. item.promoRule = '购买满' + item.orderGoodsQty + '个正价产品,可以以换购价购买任意1个换购产品'
  173. }
  174. })
  175. } else {
  176. _this.detailsData.promoRuleList = []
  177. }
  178. // 活动经费上限 单位为万元
  179. if (_this.detailsData.activeAmountEnable && _this.detailsData.activeAmountEnable == '1' && _this.detailsData.activeAmount && _this.detailsData.activeAmount != 0) {
  180. _this.detailsData.activeAmount = Number(_this.detailsData.activeAmount) / 10000
  181. }
  182. // 订单起订金额 单位为万元
  183. if (_this.detailsData.orderAmountEnable && _this.detailsData.orderAmountEnable == '1' && _this.detailsData.orderAmount && _this.detailsData.orderAmount != 0) {
  184. _this.detailsData.orderAmount = Number(_this.detailsData.orderAmount) / 10000
  185. }
  186. }
  187. })
  188. },
  189. // 查看客户
  190. handleLook (record) {
  191. this.nowColumns = this.custColumns
  192. this.lookLoadData = record || []
  193. this.openModal = true
  194. },
  195. // 查看正价品/促销品
  196. handleLookP (record, promoRuleType, goodsType) {
  197. let columns = this.pColumns
  198. this.promoRuleType = promoRuleType
  199. if ((promoRuleType == 'BUY_PROD_GIVE_PROD') || (promoRuleType == 'BUY_PROD_GIVE_MONEY')) { // 买产品送产品/买产品送采购额
  200. if (goodsType == 'normal') { // 正品
  201. columns = this.pColumns
  202. } else if (goodsType == 'promo') { // 促销
  203. columns = this.promoColumns
  204. }
  205. } else if (promoRuleType == 'PROMO_PROD') { // 特价产品
  206. if (goodsType == 'promo') { // 促销
  207. columns = this.promoSpecialColumns
  208. }
  209. } else if (promoRuleType == 'ADD_PRICE_PURCH') { // 加价换购
  210. if (goodsType == 'normal') { // 正品
  211. columns = this.pColumns
  212. } else if (goodsType == 'promo') { // 促销
  213. columns = this.promoSpecialColumns
  214. }
  215. }
  216. record.map(item => {
  217. item.name = item.goodsName
  218. })
  219. this.nowColumns = columns
  220. this.lookLoadData = record || []
  221. this.openModal = true
  222. },
  223. // 返回列表
  224. handleBack () {
  225. this.$router.push({ path: '/promotionRulesManagement/promotionRules/list', query: { closeLastOldTab: true } })
  226. },
  227. pageInit () {
  228. const _this = this
  229. this.$nextTick(() => { // 页面渲染完成后的回调
  230. _this.setTableH()
  231. })
  232. },
  233. setTableH () {
  234. this.tableHeight = window.innerHeight - 400
  235. }
  236. },
  237. watch: {
  238. detailsData: {
  239. handler (newValue, oldValue) {
  240. if (newValue.promoRuleList) {
  241. this.promoRuleList = newValue.promoRuleList
  242. }
  243. },
  244. deep: true
  245. },
  246. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  247. this.setTableH()
  248. }
  249. },
  250. mounted () {
  251. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  252. this.pageInit()
  253. this.getDetail()
  254. }
  255. },
  256. activated () {
  257. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  258. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  259. this.pageInit()
  260. this.getDetail()
  261. }
  262. },
  263. beforeRouteEnter (to, from, next) {
  264. next(vm => {})
  265. }
  266. }
  267. </script>
  268. <style lang="less">
  269. .promotionRulesDetail-wrap{
  270. position: relative;
  271. height: 100%;
  272. >.ant-spin-nested-loading{
  273. height: 100%;
  274. .ant-spin-container{
  275. height: 100%;
  276. .promotionRulesDetail-cont{
  277. min-height: 90%;
  278. }
  279. }
  280. }
  281. .promotionRulesDetail-back{
  282. margin-bottom: 10px;
  283. }
  284. .ant-descriptions-item-label.ant-descriptions-item-colon{
  285. width: 150px;
  286. }
  287. .ant-descriptions-item-content{
  288. max-width: 500px;
  289. }
  290. }
  291. </style>