detailProductList.vue 17 KB

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