detail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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 { promoActiveDetailD } from '@/api/promoActive'
  99. export default {
  100. data () {
  101. return {
  102. spinning: false,
  103. tableHeight: 0,
  104. detailsData: null,
  105. columns: [
  106. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  107. { title: '创建时间', dataIndex: 'createDate', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  108. { title: '促销类型', dataIndex: 'promoRuleTypeDictValue', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
  109. { title: '促销规则', dataIndex: 'promoRule', align: 'center', width: '37%', customRender: function (text) { return text || '--' }, ellipsis: true },
  110. { title: '操作', scopedSlots: { customRender: 'action' }, width: '18%', align: 'center' }
  111. ],
  112. loadData: [],
  113. openModal: false,
  114. custColumns: [
  115. { title: '序号', scopedSlots: { customRender: 'no' }, width: '5%', align: 'center' },
  116. { title: '客户名称', dataIndex: 'buyerName', align: 'center', width: '95%', customRender: function (text) { return text || '--' } }
  117. ],
  118. pColumns: [ // 正品
  119. { title: '序号', scopedSlots: { customRender: 'no' }, width: '4%', align: 'center' },
  120. { title: '类型', dataIndex: 'goodsTypeName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  121. { title: '类型名称', dataIndex: 'goodsName', align: 'center', width: '25%', customRender: function (text) { return text || '--' }, ellipsis: true },
  122. { title: '产品名称', dataIndex: 'name', align: 'center', width: '25%', customRender: function (text) { return text || '--' }, ellipsis: true },
  123. { title: '产品编码', dataIndex: 'goodsCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  124. { title: '起订量限制', scopedSlots: { customRender: 'orderGoodsUnit' }, width: '14%', align: 'center' }
  125. ],
  126. promoColumns: [ // 促销品
  127. { title: '序号', scopedSlots: { customRender: 'no' }, width: '5%', align: 'center' },
  128. { title: '类型', dataIndex: 'goodsTypeName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  129. { title: '类型名称', dataIndex: 'goodsName', width: '35%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  130. { title: '产品名称', dataIndex: 'name', align: 'center', width: '35%', customRender: function (text) { return text || '--' }, ellipsis: true },
  131. { title: '产品编码', dataIndex: 'goodsCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
  132. ],
  133. promoSpecialColumns: [ // 特价产品/加价促销品
  134. { title: '序号', scopedSlots: { customRender: 'no' }, width: '5%', align: 'center' },
  135. { title: '产品名称', dataIndex: 'name', align: 'center', width: '50%', customRender: function (text) { return text || '--' }, ellipsis: true },
  136. { title: '产品编码', dataIndex: 'goodsCode', width: '30%', align: 'center', customRender: function (text) { return text || '--' } },
  137. { title: this.promoRuleType == 'PROMO_PROD' ? '特惠单价(¥)' : '换购单价(¥)', width: '15%', scopedSlots: { customRender: 'goodsPrice' }, width: 200, align: 'center' }
  138. ],
  139. lookLoadData: [],
  140. promoRuleList: [],
  141. nowColumns: [],
  142. promoRuleType: '', // 当前查看类型 买产品送产品...
  143. loading: false
  144. }
  145. },
  146. methods: {
  147. // 详情
  148. getDetail () {
  149. const _this = this
  150. this.spinning = true
  151. this.loading = true
  152. promoActiveDetailD({ sn: this.$route.params.sn }).then(res => {
  153. this.loading = false
  154. this.spinning = false
  155. if (res.status == 200) {
  156. _this.detailsData = res.data
  157. if (_this.detailsData.promoRuleList) {
  158. _this.detailsData.promoRuleList.map((item, index) => {
  159. item.no = index + 1
  160. if (item.promoRuleType == 'BUY_PROD_GIVE_PROD') { // 买产品送产品
  161. item.promoRule = '购买满' + item.orderGoodsQty + '个正价产品,送' + item.promoQty + '个促销品'
  162. } else if (item.promoRuleType == 'BUY_PROD_GIVE_MONEY') { // 买产品送采购额
  163. if (item.promoType == 'promo_amount') {
  164. item.promoRule = '购买满' + item.orderAmount + '元正价产品,送' + item.promoAmount + '元采购额可用于购买促销品'
  165. } else if (item.promoType == 'promo_amount_per') {
  166. item.promoRule = '购买满' + item.orderAmount + '元正价产品可以返正价产品采购额的' + item.promoAmountPer * 100 + '%用于购买促销品'
  167. }
  168. } else if (item.promoRuleType == 'ADD_PRICE_PURCH') { // 加价换购
  169. item.promoRule = '购买满' + item.orderGoodsQty + '个正价产品,可以以换购价购买任意1个换购产品'
  170. }
  171. })
  172. } else {
  173. _this.detailsData.promoRuleList = []
  174. }
  175. // 活动经费上限 单位为万元
  176. if (_this.detailsData.activeAmountEnable && _this.detailsData.activeAmountEnable == '1' && _this.detailsData.activeAmount && _this.detailsData.activeAmount != 0) {
  177. _this.detailsData.activeAmount = Number(_this.detailsData.activeAmount) / 10000
  178. }
  179. // 订单起订金额 单位为万元
  180. if (_this.detailsData.orderAmountEnable && _this.detailsData.orderAmountEnable == '1' && _this.detailsData.orderAmount && _this.detailsData.orderAmount != 0) {
  181. _this.detailsData.orderAmount = Number(_this.detailsData.orderAmount) / 10000
  182. }
  183. }
  184. })
  185. },
  186. // 查看客户
  187. handleLook (record) {
  188. this.nowColumns = this.custColumns
  189. this.lookLoadData = record || []
  190. this.openModal = true
  191. },
  192. // 查看正价品/促销品
  193. handleLookP (record, promoRuleType, goodsType) {
  194. let columns = this.pColumns
  195. this.promoRuleType = promoRuleType
  196. if ((promoRuleType == 'BUY_PROD_GIVE_PROD') || (promoRuleType == 'BUY_PROD_GIVE_MONEY')) { // 买产品送产品/买产品送采购额
  197. if (goodsType == 'normal') { // 正品
  198. columns = this.pColumns
  199. } else if (goodsType == 'promo') { // 促销
  200. columns = this.promoColumns
  201. }
  202. } else if (promoRuleType == 'PROMO_PROD') { // 特价产品
  203. if (goodsType == 'promo') { // 促销
  204. columns = this.promoSpecialColumns
  205. }
  206. } else if (promoRuleType == 'ADD_PRICE_PURCH') { // 加价换购
  207. if (goodsType == 'normal') { // 正品
  208. columns = this.pColumns
  209. } else if (goodsType == 'promo') { // 促销
  210. columns = this.promoSpecialColumns
  211. }
  212. }
  213. record.map(item => {
  214. item.name = item.goodsName
  215. })
  216. this.nowColumns = columns
  217. this.lookLoadData = record || []
  218. this.openModal = true
  219. },
  220. // 返回列表
  221. handleBack () {
  222. this.$router.push({ path: '/promotionRulesManagement/promotionRules/list', query: { closeLastOldTab: true } })
  223. },
  224. pageInit () {
  225. const _this = this
  226. this.$nextTick(() => { // 页面渲染完成后的回调
  227. _this.setTableH()
  228. })
  229. },
  230. setTableH () {
  231. this.tableHeight = window.innerHeight - 400
  232. }
  233. },
  234. watch: {
  235. detailsData: {
  236. handler (newValue, oldValue) {
  237. if (newValue.promoRuleList) {
  238. this.promoRuleList = newValue.promoRuleList
  239. }
  240. },
  241. deep: true
  242. }
  243. },
  244. mounted () {
  245. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  246. this.pageInit()
  247. this.getDetail()
  248. }
  249. },
  250. activated () {
  251. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  252. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  253. this.pageInit()
  254. this.getDetail()
  255. }
  256. },
  257. beforeRouteEnter (to, from, next) {
  258. next(vm => {})
  259. }
  260. }
  261. </script>
  262. <style lang="less">
  263. .promotionRulesDetail-wrap{
  264. position: relative;
  265. height: 100%;
  266. >.ant-spin-nested-loading{
  267. height: 100%;
  268. .ant-spin-container{
  269. height: 100%;
  270. .promotionRulesDetail-cont{
  271. min-height: 90%;
  272. }
  273. }
  274. }
  275. .promotionRulesDetail-back{
  276. margin-bottom: 10px;
  277. }
  278. .ant-descriptions-item-label.ant-descriptions-item-colon{
  279. width: 150px;
  280. }
  281. .ant-descriptions-item-content{
  282. max-width: 500px;
  283. }
  284. }
  285. </style>