queryPart.vue 25 KB

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