detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <div class="salesDetail-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="salesDetail-cont" style="padding:16px 24px;">
  5. <template slot="subTitle">
  6. <a href="javascript:;" @click="handleBack"><a-icon type="left"></a-icon> 返回列表</a>
  7. <span style="margin: 0 10px 0 20px;color: #666;font-size: 14px;font-weight: 600;">促销名称:{{ detailData&&detailData.title||'--' }}</span>
  8. <a-button type="link" class="button-default" @click="isShowBisiceInfo=!isShowBisiceInfo">
  9. <a-icon :type="isShowBisiceInfo ? 'eye-invisible' : 'eye'"/> {{ isShowBisiceInfo?'隐藏':'查看' }}信息
  10. </a-button>
  11. </template>
  12. </a-page-header>
  13. <!-- 基础信息 -->
  14. <a-card size="small" title="基础信息" :bordered="false" v-show="!isShowBisiceInfo" class="salesDetail-cont">
  15. <a-descriptions size="small" :column="2" v-if="detailData">
  16. <a-descriptions-item label="促销名称">{{ detailData.title || '--' }}</a-descriptions-item>
  17. <a-descriptions-item label="促销简称">{{ detailData.description || '--' }}</a-descriptions-item>
  18. <a-descriptions-item label="促销时间" v-if="detailData.promotionDateStart&& detailData.promotionDateEnd">{{ detailData.promotionDateStart }}-{{ detailData.promotionDateEnd }}</a-descriptions-item>
  19. <a-descriptions-item label="促销时间" v-else>--</a-descriptions-item>
  20. <a-descriptions-item label="费用所属部门">{{ detailData.expenseDepartmentName || '--' }}</a-descriptions-item>
  21. <a-descriptions-item label="参与客户"><div @click="handleSee">共<span class="link-bule">{{ detailData.dealerQty }}</span>个</div></a-descriptions-item>
  22. <a-descriptions-item label="促销描述" :span="2">
  23. <div>{{ detailData.content || '' }}</div>
  24. </a-descriptions-item>
  25. <a-descriptions-item label="附件" :span="2">
  26. <div class="attachmentBox" v-if="detailData.attachmentList&&detailData.attachmentList.length>0">
  27. <a
  28. class="link-bule"
  29. target="downloadFile"
  30. :href="item.filePath"
  31. v-for="item in detailData.attachmentList"
  32. :key="item.id"
  33. download>{{ item.fileName }}</a>
  34. </div>
  35. <span v-else>--</span>
  36. </a-descriptions-item>
  37. </a-descriptions>
  38. </a-card>
  39. <a-card size="small" title="规则设置" :bordered="false" class="pages-wrap">
  40. <div class="btnGroup" v-if="$hasPermissions('B_rulesAddEdit')&&$route.query.type=='rule'">
  41. <a-button type="primary" class="button-warning" @click="openBtnModal('SendProducts')" :disabled="disabled">买产品送产品</a-button>
  42. <a-button style="margin:0 10px" type="primary" class="button-warn" @click="openBtnModal('SendAmount')" :disabled="disabled">买产品送采购额</a-button>
  43. <a-button type="primary" @click="openBtnModal('SpecialOffer')" :disabled="disabled">特价产品</a-button>
  44. </div>
  45. <!-- 列表 -->
  46. <s-table
  47. class="sTable"
  48. ref="table"
  49. size="small"
  50. :rowKey="(record) => record.id"
  51. :columns="columns"
  52. :data="loadData"
  53. :defaultLoadData="false"
  54. :showPagination="false"
  55. bordered>
  56. <!-- 门槛规则 -->
  57. <template slot="cillProduct" slot-scope="text, record">
  58. <div v-if="record.gateFlag === '1'">
  59. <span v-if="record.gateType==='RATIO_AMOUNT'">
  60. 购买门槛产品金额{{ record.gateAmount*100 }}%作为配额
  61. </span>
  62. <span v-else-if="record.gateType==='MIN_AMOUNT'">
  63. 购买门槛产品满最低金额{{ record.gateAmount }}元,不限制配额。
  64. </span>
  65. <span v-else>购买满{{ record.gateAmount }}元门槛产品,可使用 {{ record.quotaAmount }}元配额,采购规则中的正价商品</span>
  66. </div>
  67. <span v-else>--</span>
  68. </template>
  69. <!-- 规则 -->
  70. <template slot="ruleProduct" slot-scope="text, record">
  71. <div v-if="record.promotionRuleType == 'BUY_PROD_GIVE_PROD'">
  72. {{ record.regularSameFlag==1?'同款':'不同款' }}产品购买满{{ record.regularQty }}个正价产品,送{{ record.promotionQty }}个促销产品{{ record.promotionRuleType ==='BUY_PROD_GIVE_MONEY'?(record.accrualFlag&&record.accrualFlag==1)?'(金额叠加)':'(金额不叠加)':'' }}
  73. </div>
  74. <div v-else-if="record.promotionRuleType == 'BUY_PROD_GIVE_MONEY'">
  75. 购买满{{ record.regularAmount }}元正价产品,送{{ record.giveAmount }}元促销品采购额{{ record.promotionRuleType ==='BUY_PROD_GIVE_MONEY'?(record.accrualFlag&&record.accrualFlag==1)?'(金额叠加)':'(金额不叠加)':'' }}
  76. </div>
  77. <div v-else>
  78. 特价产品
  79. </div>
  80. </template>
  81. <!-- 操作 -->
  82. <template slot="action" slot-scope="text, record">
  83. <a-button
  84. v-if="$hasPermissions('B_rulesAddEdit')&&$route.query.type=='rule'"
  85. size="small"
  86. type="link"
  87. @click="handleEdit(record)"
  88. class="button-info"
  89. id="promotionList-edit-btn">编辑</a-button>
  90. <a-button
  91. v-if="$hasPermissions('B_rulesDel')&&$route.query.type=='rule'"
  92. size="small"
  93. type="link"
  94. @click="handleDel(record)"
  95. class="button-error"
  96. id="promotionList-del-btn">删除</a-button>
  97. <a-button
  98. v-if="$hasPermissions('B_dealerPromotionDetail')&&!$route.query.type"
  99. size="small"
  100. type="link"
  101. @click="handleDetail(record)"
  102. class="button-info"
  103. id="promotionList-edit-btn">详情</a-button>
  104. </template>
  105. </s-table>
  106. <div style="text-align:center;margin-top:20px;" v-if="$route.query.type=='rule'">
  107. <a-button
  108. type="primary"
  109. size="large"
  110. style="padding:0 30px;"
  111. @click="handleSubmit"
  112. :disabled="disabled"
  113. v-if="$hasPermissions('B_rulesSubmit')&&(mainContentList&&mainContentList.length>0)">提交</a-button>
  114. </div>
  115. </a-card>
  116. </a-spin>
  117. <!-- 查看参与客户 -->
  118. <lookUp-customers-modal ref="lookUpCustomers" :openModal="openCustomerModal" @close="openCustomerModal = false"></lookUp-customers-modal>
  119. <!-- 促销品费用归属品牌/促销品费用归属品类 -->
  120. <brandCategoryModal :openType="openType" :openModal="openModal" @close="openModal = false"></brandCategoryModal>
  121. <!-- 详情 -->
  122. <detailModal :openModal="openDetailModal" :itemSn="detailSn" @close="closeDetailModal"></detailModal>
  123. <!-- 买产品送产品 弹窗 -->
  124. <sendProductsModal :openModal="openSendProductsModal" :itemSn="detailSn" :promotionSn="$route.query.sn" @ok="$refs.table.refresh()" @close="openSendProductsModal = false"></sendProductsModal>
  125. <!-- 买产品送采购额 弹窗 -->
  126. <sendAmountModal :openModal="openSendAmountModal" :itemSn="detailSn" :promotionSn="$route.query.sn" @ok="$refs.table.refresh()" @close="openSendAmountModal = false"></sendAmountModal>
  127. <!-- 特价产品 弹窗 -->
  128. <specialOfferModal :openModal="openSpecialOfferModal" :itemSn="detailSn" :promotionSn="$route.query.sn" @ok="$refs.table.refresh()" @close="openSpecialOfferModal = false"></specialOfferModal>
  129. </div>
  130. </template>
  131. <script>
  132. import { commonMixin } from '@/utils/mixin'
  133. import { STable } from '@/components'
  134. import lookUpCustomersModal from '../promotionManagement/lookUpCustomersModal'
  135. import brandCategoryModal from './brandCategoryModal'
  136. import detailModal from './detailModal'
  137. import sendProductsModal from './sendProductsModal'
  138. import sendAmountModal from './sendAmountModal'
  139. import specialOfferModal from './specialOfferModal'
  140. import { getRuleQueryList, dealerPromotionInfo, promotionRulesDel, promotionSubmit } from '@/api/promotion'
  141. export default {
  142. name: 'SalesOrderWarehouseDetail',
  143. mixins: [commonMixin],
  144. components: { STable, lookUpCustomersModal, brandCategoryModal, detailModal, sendProductsModal, sendAmountModal, specialOfferModal },
  145. data () {
  146. return {
  147. disabled: false,
  148. spinning: false,
  149. detailData: null, // 详情数据
  150. countData: null, // 数量数据
  151. fromRouter: null,
  152. openModal: false,
  153. isShowBisiceInfo: false,
  154. openCustomerModal: false,
  155. openType: undefined,
  156. openDetailModal: false,
  157. openSendProductsModal: false,
  158. openSendAmountModal: false,
  159. openSpecialOfferModal: false,
  160. // 加载数据方法 必须为 Promise 对象
  161. loadData: parameter => {
  162. this.disabled = true
  163. this.spinning = true
  164. const dataAjax = Object.assign(parameter, { promotionSn: this.$route.query.sn })
  165. return getRuleQueryList(dataAjax).then(res => {
  166. let data
  167. if (res.status == 200) {
  168. data = res.data
  169. for (var i = 0; i < data.length; i++) {
  170. data[i].no = i + 1
  171. }
  172. this.disabled = false
  173. }
  174. this.spinning = false
  175. this.mainContentList = data
  176. return data
  177. })
  178. },
  179. detailSn: null,
  180. mainContentList: []
  181. }
  182. },
  183. computed: {
  184. columns () {
  185. const _this = this
  186. const arr = [
  187. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  188. { title: '促销类型', dataIndex: 'promotionRuleTypeDictValue', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  189. { title: '规则简称', dataIndex: 'description', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  190. { title: '规则门槛', scopedSlots: { customRender: 'cillProduct' }, width: '20%', align: 'center' },
  191. { title: '规则', scopedSlots: { customRender: 'ruleProduct' }, width: '20%', align: 'center' },
  192. { title: '订单起订金额(元)', dataIndex: 'minOrderAmount', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  193. { title: '活动经费上限(元)', dataIndex: 'upperLimitAmount', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  194. { title: '操作', scopedSlots: { customRender: 'action' }, width: '20%', align: 'center' }
  195. ]
  196. return arr
  197. }
  198. },
  199. methods: {
  200. // 打开详情弹窗
  201. handleDetail (row) {
  202. this.detailSn = row.promotionRuleSn
  203. this.openDetailModal = true
  204. },
  205. // 关闭详情弹窗
  206. closeDetailModal () {
  207. this.detailSn = null
  208. this.openDetailModal = false
  209. },
  210. // 返回
  211. handleBack () {
  212. this.$router.push({ name: 'dealerPromotionManagement' })
  213. },
  214. // 基础信息详情
  215. getDetail () {
  216. dealerPromotionInfo({ sn: this.$route.query.sn }).then(res => {
  217. if (res.status == 200) {
  218. this.$refs.table.refresh(true)
  219. if (res.data && res.data.attachmentList) {
  220. res.data.attachmentList.forEach(item => {
  221. item.filePath = item.filePath.replace(/^http:\/\//i, 'https://')
  222. })
  223. }
  224. this.detailData = res.data || null
  225. } else {
  226. this.detailData = null
  227. }
  228. })
  229. },
  230. // 买产品送产品、买产品送采购额、特价产品 弹窗
  231. openBtnModal (str) {
  232. this.detailSn = null
  233. const name = 'open' + str + 'Modal'
  234. this[name] = true
  235. },
  236. // 查看客户
  237. handleSee () {
  238. this.openCustomerModal = true
  239. this.$nextTick(() => {
  240. this.$refs.lookUpCustomers.pageInit({ dealerSnList: this.detailData.dealerSnList ? this.detailData.dealerSnList : undefined })
  241. })
  242. },
  243. // 删除规则
  244. handleDel (row) {
  245. const _this = this
  246. this.$confirm({
  247. title: '提示',
  248. content: '确认要该规则吗?',
  249. centered: true,
  250. onOk () {
  251. _this.spinning = true
  252. promotionRulesDel({ promotionSn: _this.$route.query.sn, promotionRuleSn: row.promotionRuleSn }).then(res => {
  253. if (res.status == 200) {
  254. _this.$message.success(res.message)
  255. _this.$refs.table.refresh()
  256. _this.spinning = false
  257. } else {
  258. _this.spinning = false
  259. }
  260. })
  261. }
  262. })
  263. },
  264. // 提交
  265. handleSubmit () {
  266. const _this = this
  267. _this.disabled = true
  268. promotionSubmit({ sn: _this.$route.query.sn }).then(res => {
  269. if (res.status == 200) {
  270. _this.$message.success(res.message)
  271. _this.handleBack()
  272. }
  273. _this.disabled = false
  274. })
  275. },
  276. handleEdit (row) {
  277. this.detailSn = row.promotionRuleSn
  278. if (row.promotionRuleType === 'BUY_PROD_GIVE_PROD') {
  279. this.openSendProductsModal = true
  280. } else if (row.promotionRuleType === 'BUY_PROD_GIVE_MONEY') {
  281. this.openSendAmountModal = true
  282. } else {
  283. this.openSpecialOfferModal = true
  284. }
  285. }
  286. },
  287. mounted () {
  288. if (!this.$store.state.app.isNewTab || this.outBizSubSn || this.bizSn) { // 页签刷新 或 为弹框时调用
  289. this.getDetail()
  290. }
  291. },
  292. activated () {
  293. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  294. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  295. this.getDetail()
  296. }
  297. },
  298. beforeRouteEnter (to, from, next) {
  299. next(vm => {
  300. vm.fromRouter = from
  301. })
  302. }
  303. }
  304. </script>
  305. <style lang="less" scoped>
  306. .salesDetail-wrap{
  307. .salesDetail-cont{
  308. margin-bottom: 10px;
  309. }
  310. .btnGroup{
  311. margin-bottom:15px;
  312. }
  313. .flex{
  314. display:flex;
  315. align-items: center;
  316. }
  317. .footer-cont{
  318. margin-top: 5px;
  319. text-align: center;
  320. }
  321. .attachmentBox>a::after{
  322. content:','
  323. }
  324. .attachmentBox>a:last-child::after{
  325. content:''
  326. }
  327. }
  328. </style>