queryPart.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. <template>
  2. <div class="productInfoList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchTable">
  6. <a-row :gutter="15">
  7. <a-col :md="4" :sm="24">
  8. <a-form-item label="产品名称">
  9. <a-input id="productInfoList-name" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="4" :sm="24">
  13. <a-form-item label="产品编码">
  14. <a-input id="productInfoList-code" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="4" :sm="24">
  18. <a-form-item label="是否促销品">
  19. <v-select
  20. code="FLAG"
  21. id="productInfoList-promoFlag"
  22. v-model="queryParam.promoFlag"
  23. allowClear
  24. placeholder="请选择是否"
  25. ></v-select>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="4" :sm="24">
  29. <a-form-item label="类型">
  30. <a-select v-model.trim="queryParam.pushProductType" :dropdownMatchSelectWidth="false" >
  31. <a-select-option value="">
  32. 全部产品
  33. </a-select-option>
  34. <a-select-option value="ABLE">
  35. 剩余待下推数量>0的产品
  36. </a-select-option>
  37. <a-select-option value="ALL">
  38. 可全部下推的产品
  39. </a-select-option>
  40. <a-select-option value="NOTALL">
  41. 不可全部下推的产品
  42. </a-select-option>
  43. </a-select>
  44. </a-form-item>
  45. </a-col>
  46. <a-col :md="4" :sm="24">
  47. <a-form-item label="出库仓库">
  48. <chooseWarehouse ref="warehouse" v-model="queryParam.warehouseSn"></chooseWarehouse>
  49. </a-form-item>
  50. </a-col>
  51. <a-col :md="4" :sm="24" style="margin-bottom: 10px;">
  52. <a-button type="primary" class="button-info" @click="searchTable" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  53. <a-button style="margin-left: 5px" @click="resetSearchForm" id="productInfoList-reset">重置</a-button>
  54. </a-col>
  55. </a-row>
  56. </a-form>
  57. </div>
  58. <!-- alert -->
  59. <div style="margin-bottom: 10px;display: flex;align-items: center;" v-if="detailData">
  60. <div style="display: flex;align-items: center;">
  61. <a-button type="primary" :disabled="newLoading" class="button-info" @click="handlePlAdd">批量添加</a-button>
  62. <a-button type="danger" v-if="hasPrompActive" :disabled="newLoading" class="button-error" @click="handleAllCancel">整单取消</a-button>
  63. <a-button type="danger" v-else :disabled="newLoading" class="button-error" @click="handlePlCancel">批量取消</a-button>
  64. <a-tooltip placement="top" v-if="hasPrompActive" style="margin-left:6px;">
  65. <template slot="title">
  66. <span>参加促销活动的销售单,不能单个取消产品,只能整单取消。</span>
  67. </template>
  68. <a-icon style="font-size: 14px;" type="question-circle" />
  69. </a-tooltip>
  70. <span style="margin-left: 10px;" v-if="selectedRowKeys.length">已选 {{ selectedRowKeys.length }} 项</span>
  71. </div>
  72. <div style="padding-left: 20px;">
  73. 总销售数量:<strong>{{ detailData&&(detailData.totalQty || detailData.totalQty==0) ? detailData.totalQty : '--' }}</strong>;
  74. 已取消数量:<strong>{{ detailData&&(detailData.totalCancelQty || detailData.totalCancelQty==0) ? detailData.totalCancelQty : '--' }}</strong>;
  75. 已下推数量:<strong>{{ detailData&&(detailData.totalPushedQty || detailData.totalPushedQty==0) ? detailData.totalPushedQty : '--' }}</strong>;
  76. 待下推数量:<strong>{{ detailData&&(detailData.totalUnpushedQty || detailData.totalUnpushedQty==0) ? detailData.totalUnpushedQty : '--' }}</strong>;
  77. <span v-if="$hasPermissions('B_salesDispatch_salesPrice')">总售价:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? toThousands(detailData.totalAmount) : '--' }}</strong>;</span>
  78. <span v-if="$hasPermissions('B_salesDispatch_costPrice')">总成本:<strong>{{ detailData&&(detailData.totalCost || detailData.totalCost==0) ? toThousands(detailData.totalCost) : '--' }}</strong>;</span>
  79. <span v-if="$hasPermissions('B_salesDispatch_costPrice')&&$hasPermissions('B_salesDispatch_salesPrice')">总毛利:<strong>{{ detailData&&(detailData.grossProfit || detailData.grossProfit==0) ? toThousands(detailData.grossProfit) : '--' }}</strong>;</span>
  80. <span v-if="$hasPermissions('B_salesDispatch_salesPrice')">已取消金额:<strong>{{ detailData&&(detailData.totalCancelAmount || detailData.totalCancelAmount==0) ? toThousands(detailData.totalCancelAmount) : '--' }}</strong>;</span>
  81. <span v-if="$hasPermissions('B_salesDispatch_salesPrice')">已下推金额:<strong>{{ detailData&&(detailData.totalPushedAmount || detailData.totalPushedAmount==0) ? toThousands(detailData.totalPushedAmount) :'--' }}</strong>;</span>
  82. <span v-if="$hasPermissions('B_salesDispatch_salesPrice')">待下推金额:<strong>{{ detailData&&(detailData.totalUnpushedAmount || detailData.totalUnpushedAmount==0) ? toThousands(detailData.totalUnpushedAmount) : '--' }}</strong>;</span>
  83. </div>
  84. </div>
  85. <a-spin :spinning="spinning" tip="Loading...">
  86. <ve-table
  87. border-y
  88. v-show="!showEmpty"
  89. :scroll-width="0"
  90. :max-height="tableHeight"
  91. :show-header="showTableHead"
  92. :row-style-option="{clickHighlight: true}"
  93. :cellSelectionOption="{enable: false}"
  94. :virtual-scroll-option="{enable: true}"
  95. :columns="columns"
  96. :table-data="tableData"
  97. row-key-field-name="id"
  98. :cell-style-option="cellStyleOption"
  99. :cell-span-option="cellSpanOption"
  100. :column-width-resize-option="columnWidthResizeOption"
  101. :checkbox-option="checkboxOption"
  102. />
  103. <div v-show="showEmpty" class="empty-data"><a-empty description="暂无产品" :image="simpleImage"/></div>
  104. <!-- 活动规则详情 -->
  105. <detailModal :openModal="openDetailModal" :itemSn="detailSn" @close="closeDetailModal"></detailModal>
  106. </a-spin>
  107. </div>
  108. </template>
  109. <script>
  110. import { commonMixin } from '@/utils/mixin'
  111. import { salesPromoQueryList } from '@/api/salesNew'
  112. import detailModal from '@/views/promotionRulesManagement/dealerPromotions/detailModal.vue'
  113. import { Empty } from 'ant-design-vue';
  114. import { salesDetailAllList, salesPromoDetailCount, salesDetaiCount } from '@/api/salesDetailNew'
  115. import { STable, VSelect } from '@/components'
  116. import chooseWarehouse from '@/views/common/chooseWarehouse'
  117. export default {
  118. name: 'QueryPart',
  119. mixins: [commonMixin],
  120. components: { STable, VSelect, chooseWarehouse, detailModal },
  121. props: {
  122. newLoading: {
  123. type: Boolean,
  124. default: false
  125. },
  126. maxHeight:{
  127. type: [String,Number],
  128. default: '300'
  129. },
  130. showHeader: {
  131. type: Boolean,
  132. default: true
  133. }
  134. },
  135. data () {
  136. return {
  137. advanced: true, // 高级搜索 展开/关闭
  138. openDetailModal: false,
  139. simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
  140. detailSn: null,
  141. productType: [],
  142. salesBillSn: '',
  143. detailData: null,
  144. queryParam: {
  145. pushProductType: '', // 类型
  146. productCode: '', // 产品编码
  147. productName: '', // 产品名称
  148. promoFlag: undefined, // 是否促销品
  149. brandSn: undefined, // 产品品牌
  150. productTypeSn1: '', // 产品一级分类
  151. productTypeSn2: '', // 产品二级分类
  152. productTypeSn3: '', // 产品三级分类
  153. salesBillSn: '',
  154. warehouseSn: undefined
  155. },
  156. disabled: false, // 查询、重置按钮是否可操作
  157. activeList: [], // 活动列表
  158. spinning: false,
  159. dataSource: [],
  160. tableData: [],
  161. tableHeight: this.maxHeight,
  162. cellStyleOption: {
  163. bodyCellClass: ({ row, column, rowIndex }) => {
  164. if (row.id.indexOf('promo-')>=0 && column.field === "no") {
  165. return "table-body-cell-no";
  166. }
  167. },
  168. },
  169. columnWidthResizeOption: {
  170. // default false
  171. enable: true,
  172. // column resize min width
  173. minWidth: 50
  174. },
  175. cellSpanOption: {
  176. bodyCellSpan: this.bodyCellSpan,
  177. },
  178. showEmpty: false,
  179. showTableHead: true,
  180. disableSelectedRowKeys: [],
  181. selectedRowKeys: [],
  182. colspanNums: 16,
  183. }
  184. },
  185. computed: {
  186. hasPrompActive(){
  187. return this.detailData&&this.detailData.promoFlag==1&&!this.detailData.totalCancelQty
  188. },
  189. checkboxOption () {
  190. return {
  191. disableSelectedRowKeys: this.disableSelectedRowKeys,
  192. selectedRowKeys: this.selectedRowKeys,
  193. // 行选择改变事件
  194. selectedRowChange: ({ row, isSelected, selectedRowKeys }) => {
  195. this.selectedRowChange({ row, isSelected, selectedRowKeys })
  196. },
  197. // 全选改变事件
  198. selectedAllChange: ({ isSelected, selectedRowKeys }) => {
  199. this.selectedAllChange({ isSelected, selectedRowKeys })
  200. },
  201. }
  202. },
  203. columns () {
  204. const _this = this
  205. const priceFormat = function(record,data,h){
  206. return (
  207. <div>
  208. {_this.toThousands(data)}
  209. {record.promotionFlag == 'GIFT' || record.promotionFlag == 'DISCOUNT' ? (
  210. <span title="原价">({ _this.toThousands(record.origPrice)})</span>
  211. ):''}
  212. </div>
  213. )
  214. }
  215. const numsFormat = function(data){
  216. return data || data == 0 ? data : '--'
  217. }
  218. const codeFormat = function(record,data,h){
  219. let ftext = ''
  220. let fcolor = ''
  221. if(record.promotionFlag == 'GIFT'){
  222. ftext = '促'
  223. fcolor = '#52c41a'
  224. }
  225. if(record.promotionFlag == 'GATE'){
  226. ftext = '槛'
  227. fcolor = '#108ee9'
  228. }
  229. if(record.promotionFlag == 'DISCOUNT'){
  230. ftext = '特'
  231. fcolor = '#faad14'
  232. }
  233. return (
  234. <div>
  235. <span style="padding-right: 15px;">{data}</span>
  236. {ftext?(<a-badge count={ftext} number-style={{ backgroundColor: fcolor, zoom:'80%' }}></a-badge>):''}
  237. {Number(record.stockQty||0) < Number(record.unpushedQty||0)?(<a-badge count="缺" number-style={{ zoom:'80%' }}></a-badge>):''}
  238. </div>
  239. )
  240. }
  241. // 输入框
  242. const inputFormat = function(record,data,h) {
  243. if(record.surplusQty>0){
  244. return (
  245. <div>
  246. <a-input-number
  247. size="small"
  248. value={record.cancelNums}
  249. onChange={e => _this.cancelNumsChange(e,record)}
  250. precision={0}
  251. min={0}
  252. max={record.surplusQty}
  253. style="width: 100%;"
  254. placeholder="请输入" />
  255. </div>
  256. )
  257. }
  258. return '--'
  259. }
  260. // 操作按钮
  261. const actionFormat = function(record,data,h) {
  262. if(record.surplusQty>0){
  263. return (
  264. <div>
  265. <a-button
  266. size="small"
  267. type="link"
  268. class="button-info"
  269. onClick={()=>_this.handleAdd(record)}
  270. >添加</a-button>
  271. </div>
  272. )
  273. }
  274. return '--'
  275. }
  276. // 编号,并且格式化活动分类行
  277. const noFormat = function(record,data,h){
  278. return (
  279. <div>
  280. {record.id.indexOf('promo-')>=0 ? (
  281. <div class="active-title">
  282. {record.promo?(
  283. <div>
  284. <strong style="font-size:14px;">{record.promo.promotion.description} </strong>
  285. <span>({record.promo.promotionRule.description})</span>
  286. <span style="margin-left:20px;color:#00aaff;cursor: pointer;" onClick={()=>_this.showDesc(record.promo)}>
  287. <a-icon title="查看活动详情" type="eye"/> 活动详情
  288. </span>
  289. </div>
  290. ):(<div></div>)}
  291. <div>
  292. 款数:<strong>{record.total&&record.total.totalCategory||'--'}</strong>;
  293. 数量:<strong>{record.total&&record.total.totalQty||'--'}</strong>;
  294. {_this.$hasPermissions('B_salesEdit_salesPrice') ? (<span>总金额:<strong>{record.total&&record.total.totalAmount||'--'}</strong>;</span>):('')}
  295. {_this.$hasPermissions('B_salesEdit_salesPrice')&&record.promo&&record.total&&record.total.lossAmount ? (<span>优惠金额:<strong>{record.total.lossAmount}</strong>;</span>):('')}
  296. {_this.$hasPermissions('B_salesEdit_salesPrice')&&record.promo&&record.total&&record.total.cgejyAmount>0 ? (<span>采购额结余:<strong>{_this.toThousands(record.total.cgejyAmount)}</strong>;</span>):('')}
  297. {_this.$hasPermissions('B_salesEdit_salesPrice')&&record.promo&&record.total&&record.total.cgejyAmount<0 ? (<span>采购额超出:<strong>{_this.toThousands(record.total.cgeccAmount)}</strong>;</span>):('')}
  298. {record.expenseAccountFlag!='WAIT' ? record.expenseAccountFlagDictValue : ''}
  299. </div>
  300. </div>
  301. ):(<span>{data}</span>)}
  302. </div>
  303. )
  304. }
  305. let arr= [
  306. { title: "", field: "", key: "acheck", type: "checkbox", align: "center" },
  307. { title: '序号', field: 'no',key: "a", width: 50, align: 'center', operationColumn: false,renderBodyCell: ({ row, column, rowIndex }, h) => { return noFormat(row,row[column.field],h)} },
  308. { title: '产品编码', field: 'productCode',key: "b", width: 150, align: 'center',operationColumn: false,renderBodyCell: ({ row, column, rowIndex }, h) => { return codeFormat(row,row[column.field],h)} },
  309. { title: '产品名称', field: 'productName',key: "c", width: 250, align: 'center',operationColumn: false , ellipsis: { showTitle: true },renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'}},
  310. { title: '原厂编码', field: 'productOrigCode',key: "d", width: 150, align: 'center',operationColumn: false,ellipsis: { showTitle: true },renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'} },
  311. { title: '出库仓库', field: 'warehouseName',key: "e", width: 100, align: 'center',operationColumn: false,renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'}}
  312. ]
  313. this.colspanNums = 6
  314. if (this.$hasPermissions('B_salesDispatch_salesPrice')) { // 售价权限
  315. this.colspanNums = this.colspanNums + 1
  316. arr.push({ title: '销售价', field: 'price', width: 80,key: "f", align: 'right',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return priceFormat(row,row[column.field],h)} })
  317. }
  318. if (this.$hasPermissions('B_salesDispatch_costPrice')) {
  319. this.colspanNums = this.colspanNums + 1
  320. arr.push({ title: '成本价', field: 'showCost', width: 80,key: "g", align: 'right',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return _this.toThousands(row[column.field])||'--'} })
  321. }
  322. this.colspanNums = this.colspanNums + 8
  323. arr = arr.concat([
  324. { title: '单位', field: 'productOrigUnit',key: "i", width: 80, align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'}},
  325. { title: '可用库存', field: 'stockQty', width: 80,key: "j", align: 'center',fixed: 'right',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field])} },
  326. { title: '销售数量', field: 'qty', width: 80,key: "k", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field])} },
  327. { title: '已取消', field: 'cancelQty', width: 80,key: "o", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field])} },
  328. { title: '已下推', field: 'pushedQty', width: 80,key: "p", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field])} },
  329. { title: '待下推', field: 'surplusQty', width: 80,key: "q", align: 'center',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field])} },
  330. { title: '取消数量', field: 'surplusQty', width: 80,key: "r", align: 'center',fixed: 'right',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return inputFormat(row,row[column.field],h)} },
  331. { title: '操作', field: 'action', width: 80,key: "s", align: 'center',fixed: 'right',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return actionFormat(row,row[column.field],h)} },
  332. ])
  333. return arr
  334. }
  335. },
  336. methods: {
  337. // 查看活动详情
  338. showDesc(row){
  339. this.detailSn = row.promoRuleSn
  340. this.openDetailModal = true
  341. },
  342. // 关闭详情弹窗
  343. closeDetailModal () {
  344. this.detailSn = null
  345. this.openDetailModal = false
  346. },
  347. // 合并活动分类单元格
  348. bodyCellSpan({ row, column, rowIndex }) {
  349. if (row.id.indexOf('promo-')>=0) {
  350. if(column.field=='no'){
  351. return {
  352. rowspan: 1,
  353. colspan: this.colspanNums,
  354. };
  355. }else{
  356. return {
  357. rowspan: 0,
  358. colspan: 0,
  359. }
  360. }
  361. }
  362. },
  363. cancelNumsChange(v,record){
  364. record.cancelNums = v
  365. this.dataSource.splice()
  366. },
  367. // 选择单元格
  368. selectedRowChange({ row, isSelected, selectedRowKeys }){
  369. // console.log(row, isSelected, selectedRowKeys);
  370. this.selectedRowKeys = selectedRowKeys;
  371. },
  372. // 全选行
  373. selectedAllChange({ isSelected, selectedRowKeys }){
  374. // console.log(isSelected, selectedRowKeys);
  375. this.selectedRowKeys = selectedRowKeys;
  376. },
  377. // 获取销售单参与的活动列表
  378. getActiveList(){
  379. salesPromoQueryList({ salesBillSn: this.salesBillSn }).then(res => {
  380. if(res.status == 200){
  381. this.activeList = res.data || []
  382. }
  383. this.$nextTick(()=>{
  384. this.searchTable()
  385. })
  386. })
  387. },
  388. async searchTable(){
  389. this.selectedRowKeys = []
  390. this.disableSelectedRowKeys = []
  391. this.dataSource = []
  392. this.disabled = true
  393. this.spinning = true
  394. this.queryParam.salesBillSn = this.salesBillSn
  395. this.queryParam.showStock = true
  396. const params = this.queryParam
  397. if(params.promoFlag){
  398. params.isGifg = params.promoFlag == 1 ? 'Y' : 'N'
  399. }else{
  400. params.isGifg = undefined
  401. }
  402. const active = this.activeList
  403. // 正常产品
  404. const proList = await salesDetailAllList(params).then(res => res.data)
  405. const norTotal = await salesDetaiCount(params).then(res => res.data)
  406. //没有活动时不显示统计
  407. let listData = active.length ? (proList.length ? [{
  408. id: 'promo-normal',
  409. total: norTotal
  410. },...proList] : []) : proList
  411. // 循环获取活动产品
  412. for(let i=0;i<active.length;i++){
  413. const promo = active[i]
  414. const activeParams = {
  415. promoRuleSn: promo.promoRuleSn,
  416. promoSn: promo.promoSn,
  417. salesPromoSn: promo.salesPromoSn,
  418. ...params
  419. }
  420. // 获取活动产品列表
  421. const aclist = await salesDetailAllList(activeParams).then(res => res.data)
  422. // 获取活动产品统计
  423. const acTotal = await salesPromoDetailCount(activeParams).then(res => res.data)
  424. if(acTotal){
  425. // 采购额结余
  426. acTotal.cgejyAmount = Number(acTotal.totalPromoGiftsAmount||0) - Number(acTotal.totalUsePromoGiftsAmount||0)
  427. // 采购额超出
  428. acTotal.cgeccAmount = Number(acTotal.totalUsePromoGiftsAmount||0) - Number(acTotal.totalPromoGiftsAmount||0)
  429. }
  430. const retList = [{
  431. id: 'promo-'+i,
  432. promo: promo,
  433. total: acTotal
  434. },...aclist]
  435. listData = aclist&&aclist.length ? listData.concat(retList) : listData
  436. }
  437. // 如果活动没有任何产品
  438. if(active.length){
  439. const hasAcp = listData.filter(item => item.id!='promo-normal').filter(item => item.id.indexOf("promo-")>=0)
  440. if(hasAcp && hasAcp.length==0){
  441. listData = listData.filter(item => item.id.indexOf("promo-")<0) || []
  442. }
  443. }
  444. console.log(listData)
  445. this.dataSource = listData
  446. // 格式化数据
  447. let f = 0
  448. this.dataSource.map((item,i) => {
  449. if(item.id.indexOf('promo-')>=0){f = f - 1}
  450. item.no = i + 1 + f
  451. const productCode = (item.productEntity && item.productEntity.code) || (item.dealerProductEntity && item.dealerProductEntity.code)
  452. const productName = (item.productEntity && item.productEntity.name) || (item.dealerProductEntity && item.dealerProductEntity.name)
  453. const productOrigCode = (item.productEntity && item.productEntity.origCode) || (item.dealerProductEntity && item.dealerProductEntity.origCode)
  454. const productOrigUnit = (item.productEntity && item.productEntity.unit) || (item.dealerProductEntity && item.dealerProductEntity.unit)
  455. item.productCode = productCode || '--'
  456. item.productName = productName || '--'
  457. item.productOrigCode = productOrigCode == ' ' ? '--' : productOrigCode
  458. item.productOrigUnit = productOrigUnit || '--'
  459. item.cancelNums = item.surplusQty
  460. // 库存为0或待下推数为0,不可添加
  461. if(!item.surplusQty || item.surplusQty<0){
  462. this.disableSelectedRowKeys.push(item.id)
  463. }
  464. })
  465. this.showEmpty = this.dataSource.length <= 0
  466. this.tableHeight = (this.showEmpty ? 200 : this.maxHeight) + 'px'
  467. this.tableData = this.dataSource
  468. this.spinning = false
  469. this.disabled = false
  470. },
  471. // 重置
  472. resetSearchForm () {
  473. this.queryParam.pushProductType = ''
  474. this.queryParam.productCode = ''
  475. this.queryParam.productName = ''
  476. this.queryParam.promotionFlag = undefined
  477. this.queryParam.brandSn = undefined
  478. this.queryParam.productTypeSn1 = ''
  479. this.queryParam.productTypeSn2 = ''
  480. this.queryParam.productTypeSn3 = ''
  481. this.queryParam.warehouseSn = undefined
  482. this.queryParam.promoFlag = undefined
  483. this.queryParam.isGifg = undefined
  484. this.productType = []
  485. this.dataSource = []
  486. this.clearSelectTable()
  487. this.searchTable()
  488. },
  489. pageInit (salesBillSn, detailData) {
  490. this.salesBillSn = salesBillSn
  491. this.detailData = detailData
  492. // 获取活动列表
  493. this.getActiveList()
  494. },
  495. // 清空选项
  496. clearSelectTable () {
  497. this.selectedRowKeys = []
  498. },
  499. // 添加
  500. handleAdd (row) {
  501. if (row.stockQty > 0) { // 可用库存大于0才可添加
  502. this.$emit('addProduct', [row.salesBillDetailSn])
  503. } else {
  504. this.$message.warning('库存为0,不可添加!')
  505. }
  506. },
  507. // 批量添加
  508. handlePlAdd () {
  509. const _this = this
  510. const chooseList = this.selectedRowKeys
  511. if (chooseList.length == 0) {
  512. _this.$message.warning('请先选择产品!')
  513. return
  514. }
  515. const chooseRow = this.dataSource.filter(item => chooseList.includes(item.id) && item.stockQty > 0)
  516. const obj = []
  517. chooseRow && chooseRow.map(item => {
  518. obj.push(item.salesBillDetailSn)
  519. })
  520. if(obj.length){
  521. this.$confirm({
  522. title: '提示',
  523. content: '确认要批量添加到待下推列表吗?',
  524. centered: true,
  525. closable: true,
  526. onOk () {
  527. _this.$emit('addProduct', obj)
  528. }
  529. })
  530. }else{
  531. _this.$message.warning('库存为0,不可添加!')
  532. }
  533. },
  534. // 整单取消
  535. handleAllCancel () {
  536. const _this = this
  537. this.$confirm({
  538. title: '提示',
  539. content: '确定整单取消订单?',
  540. centered: true,
  541. closable: true,
  542. onOk () {
  543. _this.$emit('cancelAll')
  544. }
  545. })
  546. },
  547. // 批量取消
  548. handlePlCancel () {
  549. const _this = this
  550. const chooseList = this.selectedRowKeys
  551. if (chooseList.length == 0) {
  552. _this.$message.warning('请先选择产品!')
  553. return
  554. }
  555. const chooseRow = this.dataSource.filter(item => chooseList.includes(item.id) && item.id.indexOf('promo-')<0)
  556. const obj = []
  557. chooseRow && chooseRow.map(item => {
  558. obj.push({
  559. 'cancelQty': item.cancelNums,
  560. 'salesBillDetailSn': item.salesBillDetailSn
  561. })
  562. })
  563. this.$emit('cancelProduct', obj)
  564. }
  565. }
  566. }
  567. </script>
  568. <style lang="less">
  569. .empty-data{
  570. color: #999;
  571. text-align: center;
  572. padding: 20px;
  573. }
  574. .ve-table-body-td{
  575. .active-title{
  576. display: flex;
  577. align-items: center;
  578. justify-content: space-between;
  579. padding: 10px;
  580. background: #f3f8fa;
  581. }
  582. }
  583. .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,
  584. .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{
  585. padding: 0;
  586. }
  587. .ve-table .ve-table-container .ve-table-content-wrapper{
  588. border-bottom: 1px solid #ddd;
  589. }
  590. </style>