detailProductList.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <template>
  2. <!-- 已选配件列表 -->
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <div :style="{position:'relative'}">
  5. <div style="height:10px;"></div>
  6. <ve-table
  7. border-y
  8. :scroll-width="0"
  9. :max-height="tableHeight"
  10. :show-header="showTableHead"
  11. :row-style-option="{clickHighlight: true}"
  12. :cellSelectionOption="{enable: false}"
  13. :virtual-scroll-option="{enable: true}"
  14. :columns="columns"
  15. :table-data="dataSource"
  16. row-key-field-name="id"
  17. :column-width-resize-option="columnWidthResizeOption"
  18. :cell-style-option="cellStyleOption"
  19. />
  20. <div v-show="showEmpty" class="empty-data"><a-empty description="暂无产品" :image="simpleImage"/></div>
  21. </div>
  22. <!-- 活动规则详情 -->
  23. <detailModal :openModal="openDetailModal" pageType="salesPage" :itemSn="detailSn" @close="closeDetailModal"></detailModal>
  24. </a-spin>
  25. </template>
  26. <script>
  27. import { commonMixin } from '@/utils/mixin'
  28. import { Empty } from 'ant-design-vue'
  29. import detailModal from '@/views/promotionRulesManagement/dealerPromotions/detailModal.vue'
  30. import { salesDetailAllList, salesDetailExtPromoList, salesDetaiCount } from '@/api/salesDetailNew'
  31. export default {
  32. name: 'DetailProductList',
  33. mixins: [commonMixin],
  34. components: { detailModal },
  35. props: {
  36. newLoading: Boolean, // loading
  37. detailData: { // 详情信息
  38. type: Object,
  39. default: function () { return null }
  40. },
  41. // 正常 or 活动 产品列表
  42. type: {
  43. type: String,
  44. default: 'normal'
  45. },
  46. // 活动规则详情
  47. promo: {
  48. type: Object,
  49. default: function () { return null }
  50. },
  51. // 表格id
  52. id: {
  53. type: String,
  54. default: ''
  55. },
  56. // 仓库sn
  57. warehouseSn: {
  58. type: String,
  59. default: ''
  60. },
  61. // 是否促销产品
  62. promoFlag: {
  63. type: String,
  64. default: ''
  65. },
  66. // 销售单sn
  67. salesBillSn: {
  68. type: String,
  69. default: ''
  70. },
  71. // 是否显示城市价格
  72. showCityPrice: {
  73. type: Boolean,
  74. default: false
  75. },
  76. // 权限码
  77. authCode: {
  78. type: String,
  79. default: ''
  80. },
  81. // 最大高度
  82. maxHeight: {
  83. type: [String, Number],
  84. default: '300'
  85. },
  86. // 是否显示表格头部
  87. showHeader: {
  88. type: Boolean,
  89. default: true
  90. },
  91. activeList: { // 参与的活动列表
  92. type: Array,
  93. default: () => []
  94. },
  95. transferQty: {// 发货经销商库存是否满足
  96. type: [String, Number],
  97. default: ''
  98. },
  99. chooseList: { // 发货经销商库存
  100. type: Array,
  101. default: function () { return [] }
  102. },
  103. showTransferDealer: {// 显示发货经销商库存
  104. type: Boolean,
  105. default: true
  106. }
  107. },
  108. data () {
  109. return {
  110. spinning: false,
  111. openDetailModal: false, // 活动规则详情弹框
  112. detailSn: null, // 活动规则详情sn
  113. dataSource: [], // 列表原始数据
  114. tableHeight: this.maxHeight, // 表格高度
  115. // 表格列可拖曳
  116. columnWidthResizeOption: {
  117. // default false
  118. enable: true,
  119. // column resize min width
  120. minWidth: 50
  121. },
  122. cellStyleOption: {
  123. headerCellClass: ({ column, rowIndex }) => {
  124. if (column.align != 'center') {
  125. return 'table-header-cell-center'
  126. }
  127. }
  128. },
  129. isCityPrice: false, // 是否显示市级价
  130. outStockStr: '', // 产品库存不足提示信息
  131. showEmpty: false, // 是否显示空数据图片
  132. showTableHead: true, // 是否显示表格头部
  133. hasOutStockOfActive: false, // 产品是否存在缺货
  134. simpleImage: Empty.PRESENTED_IMAGE_SIMPLE, // 空图片
  135. showStockCol: false, // 显示第三方库存
  136. hasJGtire: false // 是否轮胎产品
  137. }
  138. },
  139. computed: {
  140. columns () {
  141. const _this = this
  142. // 价格单元格
  143. const priceFormat = function (data) {
  144. return _this.toThousands(data) || '--'
  145. }
  146. // 数字单元格
  147. const numsFormat = function (data) {
  148. return data || data == 0 ? data : '--'
  149. }
  150. // 发货经销商库存
  151. const transferDealerInfo = function (record, data, h) {
  152. return (
  153. <div>
  154. {(!data || data && data * 1 < record.qty * 1) ? <span style="color:#ed1c24;">{data || '--'}</span> : <span>{data}</span>}
  155. </div>)
  156. }
  157. // 编号
  158. const codeFormat = function (record, data, h) {
  159. return (
  160. <div>
  161. <span style="padding-right: 10px;">{data}</span>
  162. {record.promotionFlag.indexOf('GIFT') >= 0 ? <a-badge count="促" numberStyle={{ backgroundColor: '#52c41a', zoom: '0.7' }}/> : ''}
  163. {record.promotionFlag.indexOf('DISCOUNT') >= 0 ? <a-badge count="特" numberStyle={{ backgroundColor: '#faad14', zoom: '0.7' }}/> : ''}
  164. {record.promotionFlag.indexOf('GATE') >= 0 ? <a-badge count="槛" numberStyle={{ backgroundColor: '#108ee9', zoom: '0.7' }}/> : ''}
  165. {record.promotionFlag.indexOf('REGULAR') >= 0 ? <a-badge count="正" numberStyle={{ backgroundColor: '#ff5500', zoom: '0.7' }}/> : ''}
  166. {record.convertPromoGiftsQty ? (<a-badge count="转" numberStyle={{ backgroundColor: '#ffaa00', zoom: '0.7' }}></a-badge>) : ''}
  167. {(Number(record.stockQty || 0) < Number(record.unpushedQty || 0)) && _this.showStock ? <a-badge count="缺" numberStyle={{ zoom: '0.7' }}/> : ''}
  168. </div>
  169. )
  170. }
  171. // 显示折扣价
  172. const discountPriceFormat = function (record, data, h) {
  173. return (
  174. <div>
  175. {_this.toThousands(data)}
  176. {record.promotionFlag == 'GIFT' || record.promotionFlag == 'DISCOUNT' ? (
  177. <span title="原价">({ _this.toThousands(record.origPrice)})</span>
  178. ) : ''}
  179. </div>
  180. )
  181. }
  182. // 列定义
  183. let arr = [
  184. { title: '序号', field: 'no', key: 'a', width: 50, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
  185. { title: '产品编码', field: 'productCode', key: 'b', width: 150, align: 'left', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return codeFormat(row, row[column.field], h) } },
  186. { title: '产品名称', field: 'productName', key: 'c', width: 250, align: 'left', operationColumn: false, ellipsis: { showTitle: true }, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
  187. { title: '原厂编码', field: 'productOrigCode', key: 'd', width: 150, align: 'left', operationColumn: false, ellipsis: { showTitle: true }, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
  188. { title: '出库仓库', field: 'warehouseName', key: 'e', width: 100, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } }
  189. ]
  190. // 如果是活动产品列表
  191. if (this.type == 'active') {
  192. arr.splice(3, 0, {
  193. title: '规则数量',
  194. field: 'rulesNums',
  195. key: '4',
  196. width: 60,
  197. align: 'center',
  198. operationColumn: false,
  199. renderBodyCell: ({ row, column, rowIndex }, h) => {
  200. return (
  201. row.promoRuleSnList
  202. ? <a-popover placement="right">
  203. <template slot="content">
  204. {row.promoRuleSnList.map(item => {
  205. return (
  206. <div
  207. id={'dispacth-ruleDetail-' + row.productSn}
  208. title="点击查看详情"
  209. style="padding:5px 0;cursor: pointer;"
  210. onClick={() => _this.showRuleDetail(item)}
  211. >{ _this.activeRuleFilter(item) }</div>
  212. )
  213. })}
  214. </template>
  215. <a-button type="link" id={'dispacth-ruleSn-' + row.productSn} size="small" class="button-info">
  216. {row.promoRuleNum}<span style="zoom:0.6;color: #666;">个∨</span>
  217. </a-button>
  218. </a-popover> : '--'
  219. )
  220. }
  221. })
  222. }
  223. // 计算可合并单元格数
  224. if (this.$hasPermissions(this.authCode + '_costPrice')) { // 成本价权限
  225. arr.push({ title: '成本价', field: 'showCost', width: 80, key: 'f', align: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return priceFormat(row[column.field]) } })
  226. }
  227. arr = arr.concat([
  228. { title: '单位', field: 'productOrigUnit', key: 'g', width: 80, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
  229. { title: '销售数量', field: 'qty', width: 80, key: 'h', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } }
  230. ])
  231. if (this.$hasPermissions(this.authCode + '_provincePrice')) {
  232. arr.push({ title: '省级价', field: 'provincePrice', width: 80, key: 'i', align: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return priceFormat(row[column.field]) } })
  233. }
  234. // 是否勾选市级价格
  235. if (this.isCityPrice) {
  236. arr.push({ title: '市级价', field: 'cityPrice', width: 80, key: 'j', align: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return priceFormat(row[column.field]) } })
  237. if (this.$hasPermissions(this.authCode + '_salesPrice')) { // 售价权限
  238. arr.push({ title: '销售价', field: 'price', width: 100, key: 'k', align: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return discountPriceFormat(row, row[column.field], h) } })
  239. }
  240. } else {
  241. if (this.$hasPermissions(this.authCode + '_salesPrice')) { // 售价权限
  242. arr.push({ title: '销售价', field: 'price', width: 100, key: 'l', align: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return discountPriceFormat(row, row[column.field], h) } })
  243. }
  244. }
  245. // 审核,需用到库存
  246. if (this.showStock) {
  247. arr.push({ title: '库存', field: 'stockQty', width: 80, key: 'm', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } })
  248. if (this.showStockCol) {
  249. arr.push({ title: '第三方库存', field: 'thirdStockQty', width: 80, key: 'mm', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } })
  250. }
  251. }
  252. if (this.showTransferDealer && this.type == 'normal') {
  253. arr.push({ title: '发货经销商库存', field: 'transferDealerStockQty', width: 100, key: 'tt', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return transferDealerInfo(row, row[column.field], h) } })
  254. }
  255. arr = arr.concat([
  256. { title: '待下推数', field: 'unpushedQty', width: 80, key: 'o', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } },
  257. { title: '已下推数', field: 'pushedQty', width: 80, key: 'p', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } }
  258. ])
  259. arr.push({ title: '已取消数', field: 'cancelQty', width: 80, key: 'q', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } })
  260. return arr
  261. },
  262. // 是否有可转采购额
  263. hasConvertPromoGifts () {
  264. return this.detailData && this.detailData.totalConvertPromoGiftsQty
  265. },
  266. // 是否显示库存列
  267. showStock () {
  268. return this.detailData && (this.detailData.billStatus == 'WAIT_AUDIT' || this.detailData.billStatus == 'HQ_CHANGE') && this.$hasPermissions('B_salesAudit')
  269. }
  270. },
  271. watch: {
  272. // 是否显示城市价格变化时
  273. showCityPrice (newValue, oldValue) {
  274. this.isCityPrice = newValue
  275. }
  276. },
  277. methods: {
  278. // 参与规则名称
  279. activeRuleFilter (val) {
  280. const row = this.activeList.length && this.activeList.find(item => item.promoRuleSn == val)
  281. return row ? row.promotion.description + '-' + row.promotionRule.description : ''
  282. },
  283. // 查看参与规则详情
  284. showRuleDetail (promoRuleSn) {
  285. this.detailSn = promoRuleSn
  286. this.openDetailModal = true
  287. },
  288. // 关闭详情弹窗
  289. closeDetailModal () {
  290. this.detailSn = null
  291. this.openDetailModal = false
  292. },
  293. // 获取销售单参与的活动列表
  294. pageInit () {
  295. this.searchTable()
  296. },
  297. // 显示第三方库存
  298. showThreeStock (flag) {
  299. this.showStockCol = flag
  300. if (flag) {
  301. this.searchTable()
  302. }
  303. },
  304. // 当满足发货经销商显示条件时 查询
  305. transferTableData (list) {
  306. this.dataSource = list.filter(item => this.warehouseSn != '' ? item.warehouseSn == this.warehouseSn : true).filter(item => {
  307. if (this.transferQty == '0') { // 不满足
  308. return (!item.transferDealerStockQty || (item.transferDealerStockQty && item.transferDealerStockQty * 1 < item.qty * 1))
  309. } else if (this.transferQty == '1') { // 满足
  310. return (item.transferDealerStockQty && item.transferDealerStockQty * 1 >= item.qty * 1)
  311. } else {
  312. return true
  313. }
  314. })
  315. },
  316. // 查询表格数据
  317. async searchTable () {
  318. this.dataSource = []
  319. this.disabled = true
  320. this.spinning = true
  321. // 参数
  322. const params = {
  323. salesBillSn: this.salesBillSn,
  324. showStock: this.showStock,
  325. warehouseSn: this.warehouseSn,
  326. promotionFlag: this.promoFlag == '' ? undefined : this.promoFlag
  327. }
  328. // 查询正常产品
  329. if (this.type == 'normal') {
  330. // 转单时
  331. if (this.chooseList && this.chooseList.length) {
  332. this.transferTableData(this.chooseList)
  333. } else {
  334. // 查询正常产品明细列表
  335. this.dataSource = await salesDetailAllList(params).then(res => res.data || [])
  336. }
  337. } else {
  338. // 查询活动产品明细列表
  339. this.dataSource = await salesDetailExtPromoList({ salesPromoSnSet: [], ...params }).then(res => res.data || [])
  340. }
  341. // 没用数据,则不显示当前表格
  342. if (this.dataSource.length == 0) {
  343. this.$emit('hideTable', this.type)
  344. }
  345. // 格式化数据
  346. let f = 0
  347. let str = ''
  348. this.outStockStr = ''
  349. this.dataSource.map((item, i) => {
  350. if (item.id.indexOf('promo-') >= 0) { f = f - 1 }
  351. item.no = i + 1 + f
  352. // 格式化数据,产品编码、产品名称、原厂编码、包装数单位
  353. const productCode = (item.productEntity && item.productEntity.code) || (item.dealerProductEntity && item.dealerProductEntity.code)
  354. const productName = (item.productEntity && item.productEntity.name) || (item.dealerProductEntity && item.dealerProductEntity.name)
  355. const productOrigCode = (item.productEntity && item.productEntity.origCode) || (item.dealerProductEntity && item.dealerProductEntity.origCode)
  356. const productOrigUnit = (item.productEntity && item.productEntity.unit) || (item.dealerProductEntity && item.dealerProductEntity.unit)
  357. const productBrand = (item.productEntity && item.productEntity.productBrandName) || (item.dealerProductEntity && item.dealerProductEntity.productBrandName)
  358. const productType3 = (item.productEntity && item.productEntity.productTypeName3) || (item.dealerProductEntity && item.dealerProductEntity.productTypeName3)
  359. item.productCode = productCode || '--'
  360. item.productName = productName || '--'
  361. item.productOrigCode = productOrigCode == ' ' ? '--' : productOrigCode
  362. item.productOrigUnit = productOrigUnit || '--'
  363. item.epushedQty = Number(item.pushedQty) - Number(item.pushQty)
  364. // 判断是否缺货
  365. if (item.unpushedQty && (Number(item.stockQty) < Number(item.unpushedQty))) {
  366. str += item.productCode + '、'
  367. // 参与促销活动产品是否缺货
  368. if (item.promotionFlag != 0) {
  369. this.hasOutStockOfActive = true
  370. }
  371. }
  372. // 判断是否有箭冠轮胎产品
  373. if (productBrand && productBrand.indexOf('箭冠') >= 0 && productBrand && productType3.indexOf('轮胎') >= 0) {
  374. this.hasJGtire = true
  375. }
  376. })
  377. // 是否有缺货明细
  378. if (str.length > 0) {
  379. str = str.substr(0, str.length - 1)
  380. this.outStockStr = '产品编号为:' + str + '的产品库存不足;'
  381. }
  382. const listLen = this.dataSource.length
  383. this.showEmpty = listLen <= 0
  384. // 高度自适应
  385. if (this.maxHeight == 'auto') {
  386. this.tableHeight = (listLen + 1) * 34
  387. this.tableHeight = this.tableHeight > 300 ? 300 : this.tableHeight
  388. } else {
  389. this.tableHeight = this.maxHeight
  390. }
  391. this.spinning = false
  392. this.disabled = false
  393. }
  394. }
  395. }
  396. </script>
  397. <style lang="less">
  398. .empty-data{
  399. color: #999;
  400. text-align: center;
  401. padding: 20px;
  402. position: absolute;
  403. top: 50px;
  404. width: 100%;
  405. }
  406. .table-header-cell-center{
  407. text-align: center!important;
  408. }
  409. .ant-input-number-sm input{
  410. text-align: center;
  411. }
  412. .ve-table-body-td{
  413. .active-title{
  414. display: flex;
  415. align-items: center;
  416. justify-content: space-between;
  417. padding: 10px;
  418. background: #f3f8fa;
  419. }
  420. }
  421. .ve-table .ve-table-container .ve-table-content-wrapper table.ve-table-content tbody.ve-table-body tr.ve-table-body-tr td.table-body-cell-no,
  422. .ve-table .ve-table-container .ve-table-content-wrapper table.ve-table-content tbody.ve-table-body tr.ve-table-expand-tr td.table-body-cell-no{
  423. padding: 0;
  424. }
  425. </style>