detailProductList.vue 21 KB

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