queryPart.vue 27 KB

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