detailProductList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <!-- 已选配件列表 -->
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <ve-table
  5. border-y
  6. :border-around="false"
  7. :max-height="tableHeight+'px'"
  8. :row-style-option="{clickHighlight: true}"
  9. :cellSelectionOption="{enable: false}"
  10. :virtual-scroll-option="{enable: true}"
  11. :columns="columns"
  12. :table-data="dataSource"
  13. row-key-field-name="id"
  14. :cell-style-option="cellStyleOption"
  15. />
  16. <div v-show="showEmpty" class="empty-data">暂无数据</div>
  17. </a-spin>
  18. </template>
  19. <script>
  20. import { commonMixin } from '@/utils/mixin'
  21. import { salesDetailAllList } from '@/api/salesDetailNew'
  22. export default {
  23. name: 'DetailProductList',
  24. mixins: [commonMixin],
  25. components: { },
  26. props: {
  27. newLoading: Boolean,
  28. detailData: {
  29. type: Object,
  30. default: function(){return null}
  31. },
  32. promo: {
  33. type: Object,
  34. default: function(){return null}
  35. },
  36. id: {
  37. type: String,
  38. default: ''
  39. },
  40. warehouseSn: {
  41. type: String,
  42. default: ''
  43. },
  44. salesBillSn: {
  45. type: String,
  46. default: ''
  47. },
  48. showCityPrice: {
  49. type: Boolean,
  50. default: false
  51. },
  52. authCode: {
  53. type: String,
  54. default: ''
  55. }
  56. },
  57. data () {
  58. return {
  59. spinning: false,
  60. dataSource: [],
  61. tableHeight: 200,
  62. cellStyleOption: {},
  63. isCityPrice: false,
  64. outStockStr: '',
  65. showEmpty: false
  66. }
  67. },
  68. computed: {
  69. columns () {
  70. const _this = this
  71. const priceFormat = function(data){
  72. return _this.toThousands(data) || '--'
  73. }
  74. const numsFormat = function(data){
  75. return data || data == 0 ? data : '--'
  76. }
  77. const codeFormat = function(record,data,h){
  78. if(record.promotionFlag=='GIFT'){
  79. return (
  80. <div>
  81. <span style="padding-right: 15px;">{data}</span>
  82. <a-badge count="促" number-style={{ backgroundColor: '#52c41a', zoom:'80%' }}></a-badge>
  83. </div>
  84. )
  85. }
  86. if(record.promotionFlag=='REGULAR'){
  87. return (
  88. <div>
  89. <span style="padding-right: 15px;">{data}</span>
  90. <a-badge count="正" number-style={{ backgroundColor: '#108ee9', zoom:'80%' }}></a-badge>
  91. </div>
  92. )
  93. }
  94. if(record.promotionFlag=='DISCOUNT'){
  95. return (
  96. <div>
  97. <span style="padding-right: 15px;">{data}</span>
  98. <a-badge count="特" number-style={{ backgroundColor: '#faad14', zoom:'80%' }}></a-badge>
  99. </div>
  100. )
  101. }
  102. if(Number(record.stockQty||0) < Number(record.unpushedQty||0)){
  103. return (
  104. <div>
  105. <span style="padding-right: 15px;">{data}</span>
  106. <a-badge count="缺" number-style={{ zoom:'80%' }}></a-badge>
  107. </div>
  108. )
  109. }
  110. }
  111. let arr= [
  112. { title: '序号', field: 'no',key: "a", width: 60, align: 'center', fixed: 'left',operationColumn: false },
  113. { title: '产品编码', field: 'productCode',key: "b", width: 100, align: 'center',operationColumn: false,renderBodyCell: ({ row, column, rowIndex }, h) => { return codeFormat(row,row[column.field],h)} },
  114. { title: '产品名称', field: 'productName',key: "c", width: 250, align: 'center',operationColumn: false , ellipsis: { showTitle: true },renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'}},
  115. { title: '原厂编码', field: 'productOrigCode',key: "d", width: 100, align: 'center',operationColumn: false,ellipsis: { showTitle: true },renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'} },
  116. { title: '出库仓库', field: 'warehouseName',key: "e", width: 120, align: 'center',operationColumn: false,renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'}}
  117. ]
  118. if (this.$hasPermissions(this.authCode + '_costPrice')) { // 成本价权限
  119. arr.push({ title: '成本价', field: 'showCost', width: 100,key: "f", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return priceFormat(row[column.field])} })
  120. }
  121. arr = arr.concat([
  122. { title: '单位', field: 'productOrigUnit',key: "g", width: 80, align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'}},
  123. { title: '销售数量', field: 'qty', width: 80,key: "h", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field])} }
  124. ])
  125. if (this.$hasPermissions(this.authCode + '_provincePrice')) {
  126. arr.push({ title: '省级价', field: 'provincePrice', width: 100,key: "i", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return priceFormat(row[column.field])} })
  127. }
  128. // 是否勾选市级价格
  129. if (this.isCityPrice) {
  130. arr.push({ title: '市级价', field: 'cityPrice', width: 100,key: "j", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return priceFormat(row[column.field])} })
  131. if (this.$hasPermissions(this.authCode + '_salesPrice')) { // 售价权限
  132. arr.push({ title: '销售价', field: 'price', width: 100,key: "k", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return priceFormat(row[column.field])} })
  133. }
  134. } else {
  135. if (this.$hasPermissions(this.authCode + '_salesPrice')) { // 售价权限
  136. arr.push({ title: '销售价', field: 'price', width: 100,key: "l", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return priceFormat(row[column.field])} })
  137. }
  138. }
  139. if (this.showStock) { // 审核,需用到库存
  140. arr.push({ title: '库存', field: 'stockQty', width: 100,key: "m", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field])} })
  141. }
  142. arr = arr.concat([
  143. { title: '待下推数', field: 'unpushedQty', width: 100,key: "o", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field])} },
  144. { title: '已下推数', field: 'pushedQty', width: 100,key: "p", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field])} },
  145. { title: '已取消数', field: 'cancelQty', width: 100,key: "q", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field])} }
  146. ])
  147. return arr
  148. },
  149. showStock(){
  150. return this.detailData && (this.detailData.billStatus == 'WAIT_AUDIT' || this.detailData.billStatus == 'HQ_CHANGE') && this.$hasPermissions('B_salesAudit')
  151. }
  152. },
  153. watch: {
  154. showCityPrice(newValue, oldValue){
  155. this.isCityPrice = newValue
  156. },
  157. salesBillSn(newValue, oldValue){
  158. }
  159. },
  160. methods: {
  161. // 获取表格数据
  162. getTableData(){
  163. this.spinning = true
  164. const params = {
  165. salesBillSn: this.salesBillSn,
  166. showStock: this.showStock,
  167. warehouseSn: this.warehouseSn
  168. }
  169. // 活动列表
  170. if(this.promo){
  171. params.promoRuleSn = this.promo.promoRuleSn
  172. params.promoSn = this.promo.promoSn
  173. params.salesPromoSn = this.promo.salesPromoSn
  174. }
  175. salesDetailAllList(params).then(res => {
  176. let data
  177. if (res.status == 200) {
  178. data = res.data
  179. const no = 0
  180. this.outStockStr = ''
  181. let str = ''
  182. for (var i = 0; i < data.length; i++) {
  183. data[i].no = no + i + 1
  184. const productCode = (data[i].productEntity && data[i].productEntity.code) || (data[i].dealerProductEntity && data[i].dealerProductEntity.code)
  185. const productName = (data[i].productEntity && data[i].productEntity.name) || (data[i].dealerProductEntity && data[i].dealerProductEntity.name)
  186. const productOrigCode = (data[i].productEntity && data[i].productEntity.origCode) || (data[i].dealerProductEntity && data[i].dealerProductEntity.origCode)
  187. const productOrigUnit = (data[i].productEntity && data[i].productEntity.unit) || (data[i].dealerProductEntity && data[i].dealerProductEntity.unit)
  188. data[i].productCode = productCode || '--'
  189. data[i].productName = productName || '--'
  190. data[i].productOrigCode = productOrigCode == ' ' ? '--' : productOrigCode
  191. data[i].productOrigUnit = productOrigUnit || '--'
  192. if (data[i].unpushedQty && (Number(data[i].stockQty) < Number(data[i].unpushedQty))) {
  193. str += data[i].productCode + '、'
  194. }
  195. }
  196. if (str.length > 0) {
  197. str = str.substr(0, str.length - 1)
  198. this.outStockStr = '产品编号为:' + str + '的产品库存不足;'
  199. }
  200. this.showEmpty = data.length <= 0
  201. this.tableHeight = this.showEmpty ? 30 : 200
  202. this.spinning = false
  203. this.dataSource = data
  204. }
  205. })
  206. }
  207. }
  208. }
  209. </script>
  210. <style lang="less">
  211. .empty-data{
  212. color: #999;
  213. text-align: center;
  214. padding: 20px;
  215. }
  216. </style>