detailProductList.vue 19 KB

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