detailProductList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <!-- 已选配件列表 -->
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <ve-table
  5. border-y
  6. v-show="!showEmpty"
  7. :scroll-width="0"
  8. :max-height="tableHeight"
  9. :show-header="showTableHead"
  10. :row-style-option="{clickHighlight: true}"
  11. :cellSelectionOption="{enable: false}"
  12. :virtual-scroll-option="{enable: true}"
  13. :columns="columns"
  14. :table-data="dataSource"
  15. row-key-field-name="id"
  16. :cell-style-option="cellStyleOption"
  17. :cell-span-option="cellSpanOption"
  18. :column-width-resize-option="columnWidthResizeOption"
  19. />
  20. <div v-show="showEmpty" class="empty-data">暂无数据</div>
  21. </a-spin>
  22. </template>
  23. <script>
  24. import { commonMixin } from '@/utils/mixin'
  25. import { salesPromoQueryList } from '@/api/salesNew'
  26. import { salesDetailAllList, salesPromoDetailCount, salesDetaiCount } from '@/api/salesDetailNew'
  27. export default {
  28. name: 'DetailProductList',
  29. mixins: [commonMixin],
  30. components: { },
  31. props: {
  32. newLoading: Boolean,
  33. detailData: {
  34. type: Object,
  35. default: function(){return null}
  36. },
  37. promo: {
  38. type: Object,
  39. default: function(){return null}
  40. },
  41. id: {
  42. type: String,
  43. default: ''
  44. },
  45. warehouseSn: {
  46. type: String,
  47. default: ''
  48. },
  49. salesBillSn: {
  50. type: String,
  51. default: ''
  52. },
  53. showCityPrice: {
  54. type: Boolean,
  55. default: false
  56. },
  57. authCode: {
  58. type: String,
  59. default: ''
  60. },
  61. maxHeight:{
  62. type: [String,Number],
  63. default: '300'
  64. },
  65. showHeader: {
  66. type: Boolean,
  67. default: true
  68. }
  69. },
  70. data () {
  71. return {
  72. spinning: false,
  73. activeList: [], // 活动列表
  74. dataSource: [],
  75. tableHeight: this.maxHeight,
  76. cellStyleOption: {
  77. bodyCellClass: ({ row, column, rowIndex }) => {
  78. if (row.id.indexOf('promo-')>=0 && column.field === "no") {
  79. return "table-body-cell-no";
  80. }
  81. },
  82. },
  83. columnWidthResizeOption: {
  84. // default false
  85. enable: true,
  86. // column resize min width
  87. minWidth: 50
  88. },
  89. cellSpanOption: {
  90. bodyCellSpan: this.bodyCellSpan,
  91. },
  92. isCityPrice: false,
  93. outStockStr: '',
  94. showEmpty: false,
  95. showTableHead: true,
  96. colspanNums: 13
  97. }
  98. },
  99. computed: {
  100. columns () {
  101. const _this = this
  102. const priceFormat = function(data){
  103. return _this.toThousands(data) || '--'
  104. }
  105. const numsFormat = function(data){
  106. return data || data == 0 ? data : '--'
  107. }
  108. const codeFormat = function(record,data,h){
  109. let ftext = ''
  110. let fcolor = ''
  111. if(record.promotionFlag == 'GIFT'){
  112. ftext = '促'
  113. fcolor = '#52c41a'
  114. }
  115. // if(record.promotionFlag == 'REGULAR'){
  116. // ftext = '正'
  117. // fcolor = '#108ee9'
  118. // }
  119. if(record.promotionFlag == 'DISCOUNT'){
  120. ftext = '特'
  121. fcolor = '#faad14'
  122. }
  123. return (
  124. <div>
  125. <span style="padding-right: 15px;">{data}</span>
  126. {ftext?(<a-badge count={ftext} number-style={{ backgroundColor: fcolor, zoom:'80%' }}></a-badge>):''}
  127. {Number(record.stockQty||0) < Number(record.unpushedQty||0)?(<a-badge count="缺" number-style={{ zoom:'80%' }}></a-badge>):''}
  128. </div>
  129. )
  130. }
  131. // 编号,并且格式化活动分类行
  132. const noFormat = function(record,data,h){
  133. return (
  134. <div>
  135. {record.id.indexOf('promo-')>=0 ? (
  136. <div class="active-title">
  137. {record.promo?(
  138. <div>
  139. <strong style="margin-right:10px;font-size:14px;">{record.promo.promotion.title} ({record.promo.promotionRule.description})</strong>
  140. <span style="margin-left:10px;color:#00aaff;cursor: pointer;" onClick={()=>_this.showDesc(record)}>
  141. <a-icon title="查看活动详情" type="eye"/> 活动详情
  142. </span>
  143. </div>
  144. ):(<div></div>)}
  145. <div>
  146. 款数:<strong>{record.total&&record.total.totalCategory||'--'}</strong>
  147. 数量:<strong>{record.total&&record.total.totalQty||'--'}</strong>
  148. {_this.$hasPermissions('B_salesEdit_salesPrice') ? (<span>总金额:<strong>{record.total&&record.total.totalAmount||'--'}</strong></span>):('')}
  149. {_this.$hasPermissions('B_salesEdit_salesPrice')&&record.promo&&record.total ? (<span>优惠金额:<strong>{record.total.lossAmount||'--'}</strong></span>):('')}
  150. {_this.$hasPermissions('B_salesEdit_salesPrice')&&record.promo&&record.total ? (<span>采购额结余:<strong>{_this.toThousands(Number(record.total.totalPromoGiftsAmount) - Number(record.total.totalUsePromoGiftsAmount))}</strong></span>):('')}
  151. {_this.$hasPermissions('B_salesEdit_salesPrice')&&record.promo&&record.total ? (<span>采购额超出:<strong>{_this.toThousands(Number(record.total.totalUsePromoGiftsAmount) - Number(record.total.totalPromoGiftsAmount))}</strong></span>):('')}
  152. {record.expenseAccountFlagDictValue||''}
  153. </div>
  154. </div>
  155. ):(<span>{data}</span>)}
  156. </div>
  157. )
  158. }
  159. // 显示折扣价
  160. const discountPriceFormat = function(record,data,h) {
  161. if(record.promotionFlag == 'GIFT' || record.promotionFlag == 'DISCOUNT'){
  162. return _this.toThousands(record.discountedPrice) + '(' + _this.toThousands(data) + ')'
  163. }
  164. return _this.toThousands(data)
  165. }
  166. let arr= [
  167. { title: '序号', field: 'no',key: "a", width: 50, align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return noFormat(row,row[column.field],h)} },
  168. { title: '产品编码', field: 'productCode',key: "b", width: 150, align: 'center',operationColumn: false,renderBodyCell: ({ row, column, rowIndex }, h) => { return codeFormat(row,row[column.field],h)} },
  169. { title: '产品名称', field: 'productName',key: "c", width: 250, align: 'center',operationColumn: false , ellipsis: { showTitle: true },renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'}},
  170. { title: '原厂编码', field: 'productOrigCode',key: "d", width: 150, align: 'center',operationColumn: false,ellipsis: { showTitle: true },renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'} },
  171. { title: '出库仓库', field: 'warehouseName',key: "e", width: 100, align: 'center',operationColumn: false,renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'}}
  172. ]
  173. this.colspanNums = 5
  174. if (this.$hasPermissions(this.authCode + '_costPrice')) { // 成本价权限
  175. this.colspanNums = this.colspanNums + 1
  176. arr.push({ title: '成本价', field: 'showCost', width: 80,key: "f", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return priceFormat(row[column.field])} })
  177. }
  178. this.colspanNums = this.colspanNums + 2
  179. arr = arr.concat([
  180. { title: '单位', field: 'productOrigUnit',key: "g", width: 80, align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'}},
  181. { title: '销售数量', field: 'qty', width: 80,key: "h", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field])} }
  182. ])
  183. if (this.$hasPermissions(this.authCode + '_provincePrice')) {
  184. this.colspanNums = this.colspanNums + 1
  185. arr.push({ title: '省级价', field: 'provincePrice', width: 80,key: "i", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return priceFormat(row[column.field])} })
  186. }
  187. // 是否勾选市级价格
  188. if (this.isCityPrice) {
  189. this.colspanNums = this.colspanNums + 1
  190. arr.push({ title: '市级价', field: 'cityPrice', width: 80,key: "j", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return priceFormat(row[column.field])} })
  191. if (this.$hasPermissions(this.authCode + '_salesPrice')) { // 售价权限
  192. this.colspanNums = this.colspanNums + 1
  193. arr.push({ title: '销售价', field: 'price', width: 80,key: "k", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return discountPriceFormat(row,row[column.field],h)} })
  194. }
  195. } else {
  196. if (this.$hasPermissions(this.authCode + '_salesPrice')) { // 售价权限
  197. this.colspanNums = this.colspanNums + 1
  198. arr.push({ title: '销售价', field: 'price', width: 80,key: "l", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return discountPriceFormat(row,row[column.field],h)} })
  199. }
  200. }
  201. if (this.showStock) { // 审核,需用到库存
  202. this.colspanNums = this.colspanNums + 1
  203. arr.push({ title: '库存', field: 'stockQty', width: 80,key: "m", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field])} })
  204. }
  205. this.colspanNums = this.colspanNums + 3
  206. arr = arr.concat([
  207. { title: '待下推数', field: 'unpushedQty', width: 80,key: "o", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field])} },
  208. { title: '已下推数', field: 'pushedQty', width: 80,key: "p", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field])} },
  209. { title: '已取消数', field: 'cancelQty', width: 80,key: "q", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field])} }
  210. ])
  211. return arr
  212. },
  213. showStock(){
  214. return this.detailData && (this.detailData.billStatus == 'WAIT_AUDIT' || this.detailData.billStatus == 'HQ_CHANGE') && this.$hasPermissions('B_salesAudit')
  215. }
  216. },
  217. watch: {
  218. showCityPrice(newValue, oldValue){
  219. this.isCityPrice = newValue
  220. }
  221. },
  222. methods: {
  223. // 合并活动分类单元格
  224. bodyCellSpan({ row, column, rowIndex }) {
  225. if (row.id.indexOf('promo-')>=0) {
  226. if(column.field=='no'){
  227. return {
  228. rowspan: 1,
  229. colspan: this.colspanNums,
  230. };
  231. }else{
  232. return {
  233. rowspan: 0,
  234. colspan: 0,
  235. }
  236. }
  237. }
  238. },
  239. // 查看活动详情
  240. showDesc(e,item){
  241. },
  242. // 获取销售单参与的活动列表
  243. pageInit(){
  244. salesPromoQueryList({ salesBillSn: this.salesBillSn }).then(res => {
  245. if(res.status == 200){
  246. this.activeList = res.data || []
  247. }
  248. this.$nextTick(()=>{
  249. this.searchTable()
  250. })
  251. })
  252. },
  253. async searchTable(){
  254. this.dataSource = []
  255. this.disabled = true
  256. this.spinning = true
  257. // 参数
  258. const params = {
  259. salesBillSn: this.salesBillSn,
  260. showStock: this.showStock,
  261. warehouseSn: this.warehouseSn
  262. }
  263. // 正常产品
  264. const proList = await salesDetailAllList(params).then(res => res.data)
  265. const norTotal = await salesDetaiCount(params).then(res => res.data)
  266. let listData = [{
  267. id: 'promo-normal',
  268. total: norTotal
  269. },...proList]
  270. // 循环获取活动产品
  271. const active = this.activeList
  272. for(let i=0;i<active.length;i++){
  273. const promo = active[i]
  274. const activeParams = {
  275. promoRuleSn: promo.promoRuleSn,
  276. promoSn: promo.promoSn,
  277. salesPromoSn: promo.salesPromoSn,
  278. ...params
  279. }
  280. // 获取活动产品列表
  281. const aclist = await salesDetailAllList(activeParams).then(res => res.data)
  282. // 获取活动产品统计
  283. const acTotal = await salesPromoDetailCount(activeParams).then(res => res.data)
  284. const retList = [{
  285. id: 'promo-'+i,
  286. promo: promo,
  287. total: acTotal
  288. },...aclist]
  289. listData = aclist&&aclist.length ? listData.concat(retList) : listData
  290. }
  291. console.log(listData)
  292. this.dataSource = listData
  293. // 格式化数据
  294. let f = 0
  295. this.outStockStr = ''
  296. let str = ''
  297. this.dataSource.map((item,i) => {
  298. if(item.id.indexOf('promo-')>=0){f = f - 1}
  299. item.no = i + 1 + f
  300. const productCode = (item.productEntity && item.productEntity.code) || (item.dealerProductEntity && item.dealerProductEntity.code)
  301. const productName = (item.productEntity && item.productEntity.name) || (item.dealerProductEntity && item.dealerProductEntity.name)
  302. const productOrigCode = (item.productEntity && item.productEntity.origCode) || (item.dealerProductEntity && item.dealerProductEntity.origCode)
  303. const productOrigUnit = (item.productEntity && item.productEntity.unit) || (item.dealerProductEntity && item.dealerProductEntity.unit)
  304. item.productCode = productCode || '--'
  305. item.productName = productName || '--'
  306. item.productOrigCode = productOrigCode == ' ' ? '--' : productOrigCode
  307. item.productOrigUnit = productOrigUnit || '--'
  308. if (item.unpushedQty && (Number(item.stockQty) < Number(item.unpushedQty))) {
  309. str += item.productCode + '、'
  310. }
  311. })
  312. if (str.length > 0) {
  313. str = str.substr(0, str.length - 1)
  314. this.outStockStr = '产品编号为:' + str + '的产品库存不足;'
  315. }
  316. this.showEmpty = this.dataSource.length <= 0
  317. this.tableHeight = (this.showEmpty ? 200 : this.maxHeight) + 'px'
  318. this.spinning = false
  319. this.disabled = false
  320. },
  321. }
  322. }
  323. </script>
  324. <style lang="less">
  325. .empty-data{
  326. color: #999;
  327. text-align: center;
  328. padding: 20px;
  329. }
  330. .ve-table-body-td{
  331. .active-title{
  332. display: flex;
  333. align-items: center;
  334. justify-content: space-between;
  335. padding: 10px;
  336. background: #f3f8fa;
  337. }
  338. }
  339. .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,
  340. .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{
  341. padding: 0;
  342. }
  343. </style>