productActiveList.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. <template>
  2. <div style="position: relative;">
  3. <!-- 已选配件列表 -->
  4. <a-spin :spinning="spinning" tip="Loading...">
  5. <!-- 筛选条件 -->
  6. <div class="table-page-search-wrapper" style="margin:0" v-show="showSearchBox">
  7. <a-form layout="inline" @keyup.enter.native="searchProduct">
  8. <a-row :gutter="15" type="flex">
  9. <a-col flex="1">
  10. <a-form-item label="出库仓库" prop="warehouseSn">
  11. <chooseWarehouse
  12. style="width:100%;"
  13. :id="'salesEdit-warehouseSn-'+id"
  14. ref="warehouse"
  15. v-model="queryParam.warehouseSn"
  16. @load="warehouseLoad"></chooseWarehouse>
  17. </a-form-item>
  18. </a-col>
  19. <a-col flex="1">
  20. <a-form-item label="产品编码" prop="productCode">
  21. <a-input
  22. style="width:100%;"
  23. :id="'salesEdit-productCode-'+id"
  24. v-model.trim="queryParam.productCode"
  25. placeholder="请输入产品编码"
  26. allowClear />
  27. </a-form-item>
  28. </a-col>
  29. <a-col flex="1">
  30. <a-form-item label="产品名称" prop="productName">
  31. <a-input
  32. style="width:100%;"
  33. :id="'salesEdit-productName-'+id"
  34. v-model.trim="queryParam.productName"
  35. placeholder="请输入产品名称"
  36. allowClear />
  37. </a-form-item>
  38. </a-col>
  39. <a-col flex="1">
  40. <a-form-item label="品牌">
  41. <ProductBrand :id="'salesEdit-productBrandSn-'+id" v-model="queryParam.productBrandSn"></ProductBrand>
  42. </a-form-item>
  43. </a-col>
  44. <a-col flex="1">
  45. <a-form-item label="产品分类">
  46. <productTypeAll
  47. style="width:100%;"
  48. :id="'salesEdit-productType-'+id"
  49. size="small"
  50. placeholder="请选择产品分类"
  51. @change="changeProductType"
  52. v-model="productType"></productTypeAll>
  53. </a-form-item>
  54. </a-col>
  55. <a-col flex="1">
  56. <a-form-item label="满足起订量">
  57. <v-select code="FLAG" v-model="queryParam.unitFlag" allowClear placeholder="请选择是否满足起订量"></v-select>
  58. </a-form-item>
  59. </a-col>
  60. <a-col flex="1">
  61. <a-form-item label="产品类型">
  62. <a-select
  63. v-model="queryParam.promoProductClz"
  64. id="salesEdit-promoFlag"
  65. allowClear
  66. :dropdownMatchSelectWidth="false"
  67. placeholder="请选择产品类型">
  68. <a-select-option value="REGULAR">
  69. 正价产品(活动)
  70. </a-select-option>
  71. <a-select-option value="DISCOUNT">
  72. 特价产品
  73. </a-select-option>
  74. <a-select-option value="GIFT">
  75. 促销产品
  76. </a-select-option>
  77. <a-select-option value="GATE">
  78. 门槛产品
  79. </a-select-option>
  80. </a-select>
  81. </a-form-item>
  82. </a-col>
  83. <a-col flex="1">
  84. <a-form-item label="累计产品">
  85. <v-select code="FLAG" v-model="queryParam.borrowFlag" allowClear placeholder="请选择是否累计产品"></v-select>
  86. </a-form-item>
  87. </a-col>
  88. <a-col flex="2" style="margin-bottom: 10px;">
  89. <a-button type="primary" @click="searchProduct" :disabled="disabled" :id="'salesEdit-refresh-'+id">查询</a-button>
  90. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" :id="'salesEdit-reset-'+id">重置</a-button>
  91. </a-col>
  92. </a-row>
  93. </a-form>
  94. </div>
  95. <div class="table-page-search-wrapper">
  96. <a-row :gutter="15" type="flex" justify="space-between" align="middle">
  97. <a-col :md="8" :sm="24" style="text-align:left;">
  98. <a-dropdown>
  99. <a-menu slot="overlay" @click="handleMenuClick" :id="'salesEdit-menu-'+id">
  100. <!-- <a-menu-item key="3" :id="'salesEdit-menu-3-'+id">
  101. 全部仓库设置
  102. </a-menu-item>
  103. <a-menu-item key="2" :id="'salesEdit-menu-2-'+id">
  104. 全部删除
  105. </a-menu-item>
  106. <a-menu-divider /> -->
  107. <a-menu-item key="0" :id="'salesEdit-menu-0-'+id">
  108. 部分仓库设置
  109. </a-menu-item>
  110. <a-menu-item key="1" :id="'salesEdit-menu-1-'+id">
  111. 删除已选项
  112. </a-menu-item>
  113. <a-menu-item key="4" :id="'salesEdit-menu-4-'+id">
  114. 批量取消促销
  115. </a-menu-item>
  116. </a-menu>
  117. <a-button
  118. :id="'salesEdit-plaction-'+id"
  119. type="default"
  120. class="button-info"
  121. size="small"
  122. >批量操作<a-icon type="down" /> </a-button>
  123. </a-dropdown>
  124. <span v-if="selectTotal" style="margin:0 10px;">已选 {{ selectTotal }} 项</span>
  125. <a-button
  126. :id="'salesEdit-allSetWare-'+id"
  127. type="link"
  128. class="button-info"
  129. size="small"
  130. @click="handleMenuClick({key:3})"
  131. ><a-icon type="setting"/> 全部仓库设置</a-button>
  132. <a-button
  133. :id="'salesEdit-allDel-'+id"
  134. type="link"
  135. class="button-error"
  136. size="small"
  137. @click="handleMenuClick({key:2})"
  138. ><a-icon type="delete"/> 全部删除</a-button>
  139. </a-col>
  140. <a-col :md="12" :sm="24" style="text-align:right;">
  141. <a-button
  142. :id="'salesEdit-searchBox-'+id"
  143. type="link"
  144. class="button-info"
  145. @click="showSearchBox=!showSearchBox" ><a-icon :type="showSearchBox?'close':'search'"/> 筛选</a-button>
  146. </a-col>
  147. </a-row>
  148. </div>
  149. <ve-table
  150. style="width:100%"
  151. border-y
  152. border-x
  153. border-around
  154. :max-height="tableHeight"
  155. :scroll-width="0"
  156. :column-width-resize-option="columnWidthResizeOption"
  157. :row-style-option="{clickHighlight: true}"
  158. :cellSelectionOption="{enable: false}"
  159. :virtual-scroll-option="{enable: true}"
  160. :columns="columns"
  161. :table-data="dataSource"
  162. row-key-field-name="id"
  163. :checkbox-option="checkboxOption"
  164. :cell-style-option="cellStyleOption"
  165. />
  166. <div v-show="dataSource.length==0" class="empty-data2"><a-empty description="暂无数据" :image="simpleImage"/></div>
  167. </a-spin>
  168. <!-- 仓库设置 -->
  169. <setWarehouse :title="warehouseTit" :show="openWarehouseModal" @ok="chooseWarehouseOk" @cancel="openWarehouseModal=false"></setWarehouse>
  170. <!-- 换促销 -->
  171. <updateActiveModal ref="updateActive" :pageType="true" :show="openUpActiveModal" @ok="upActiveOk" @cancel="openUpActiveModal=false"></updateActiveModal>
  172. </div>
  173. </template>
  174. <script>
  175. import { commonMixin } from '@/utils/mixin'
  176. import { Empty } from 'ant-design-vue'
  177. import { VSelect } from '@/components'
  178. import setWarehouse from './setWarehouse.vue'
  179. import updateActiveModal from './updateActiveModal.vue'
  180. import chooseWarehouse from '@/views/common/chooseWarehouse'
  181. import ProductBrand from '@/views/common/productBrand.js'
  182. import productTypeAll from '@/views/common/productTypeAll.js'
  183. import {
  184. salesDetailExtPromoList,
  185. salesDetailUpdateQty,
  186. salesDetailInsert,
  187. salesDetailInsertBatchBorrow,
  188. salesDetailDel,
  189. salesDetailBatchDel,
  190. deletePromoAll,
  191. updateWarehouse
  192. } from '@/api/salesDetailNew'
  193. export default {
  194. name: 'ProductList',
  195. mixins: [commonMixin],
  196. components: {
  197. VSelect,
  198. chooseWarehouse,
  199. setWarehouse, // 设置仓库组件
  200. ProductBrand, // 产品品牌组件
  201. productTypeAll, // 产品分类组件
  202. updateActiveModal// 更换活动弹框组件
  203. },
  204. props: {
  205. openModal: { // 弹框显示状态
  206. type: Boolean,
  207. default: false
  208. },
  209. newLoading: Boolean,
  210. // 详情数据
  211. detailData: {
  212. type: Object,
  213. default: function () { return null }
  214. },
  215. // 表格id
  216. id: {
  217. type: String,
  218. default: '0'
  219. },
  220. activeList: {
  221. type: Array,
  222. default: () => []
  223. },
  224. // 已勾选的活动sn
  225. salesPromoSnSet: {
  226. type: Array,
  227. default: () => []
  228. },
  229. // 销售单sn
  230. salesBillSn: {
  231. type: String,
  232. default: ''
  233. }
  234. },
  235. data () {
  236. return {
  237. spinning: false,
  238. simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
  239. // 表格列宽拖到
  240. columnWidthResizeOption: {
  241. // default false
  242. enable: true,
  243. // column resize min width
  244. minWidth: 50
  245. },
  246. cellStyleOption: {
  247. headerCellClass: ({ column, rowIndex }) => {
  248. if (column.align != 'center') {
  249. return 'table-header-cell-center'
  250. }
  251. }
  252. },
  253. dataSource: [],
  254. showSearchBox: true, // 是否显示筛选条件
  255. openWarehouseModal: false, // 打开仓库设置
  256. delLoading: false, // 删除logding
  257. disabled: false, // 查询、重置按钮是否可操作
  258. queryParam: {
  259. warehouseSn: undefined, // 仓库
  260. productCode: '', // 产品编码
  261. productName: '', // 产品名称
  262. productBrandSn: undefined, // 产品品牌
  263. productTypeSn1: '', // 产品一级分类
  264. productTypeSn2: '', // 产品二级分类
  265. productTypeSn3: '', // 产品三级分类
  266. promoProductClz: undefined, // 产品类型
  267. promoFlag: undefined,
  268. borrowFlag: undefined, // 是否累计
  269. unitFlag: undefined // 是否满足起订量
  270. },
  271. productType: [], // 已选产品分类
  272. disableSelectedRowKeys: [], // 禁用的行
  273. selectedRowKeys: [], // 已选行
  274. warehouseDataList: [], // 仓库列表数据
  275. openUpActiveModal: false, // 更换促销活动弹框
  276. descDetail: null, // 规则详细数据
  277. countData: null, // 统计信息
  278. warehouseTit: '', // 仓库设置唐卡标题
  279. showStockCol: false, // 第三方库存是否显示
  280. promo: null
  281. }
  282. },
  283. computed: {
  284. // 已选产品数量
  285. selectTotal () {
  286. return this.selectedRowKeys.length || 0
  287. },
  288. tableHeight () {
  289. const len = this.dataSource.length
  290. if (len == 0) return 300
  291. return len <= 10 ? ((len + 1) * 36) + 'px' : '360px'
  292. },
  293. // 表格复选框设置
  294. checkboxOption () {
  295. return {
  296. disableSelectedRowKeys: this.disableSelectedRowKeys,
  297. selectedRowKeys: this.selectedRowKeys,
  298. // 行选择改变事件
  299. selectedRowChange: ({ row, isSelected, selectedRowKeys }) => {
  300. this.selectedRowChange({ row, isSelected, selectedRowKeys })
  301. },
  302. // 全选改变事件
  303. selectedAllChange: ({ isSelected, selectedRowKeys }) => {
  304. this.selectedAllChange({ isSelected, selectedRowKeys })
  305. }
  306. }
  307. },
  308. // 表格列
  309. columns () {
  310. const _this = this
  311. // 价格
  312. const priceFormat = function (data) {
  313. return _this.toThousands(data) || '--'
  314. }
  315. // 显示折扣价
  316. const discountPriceFormat = function (record, data, h) {
  317. return (
  318. <div>
  319. {_this.toThousands(data)}
  320. {record.promotionFlag.indexOf('GIFT') >= 0 || record.promotionFlag.indexOf('DISCOUNT') >= 0 ? (
  321. <span title="原价">({ _this.toThousands(record.origPrice)})</span>
  322. ) : ''}
  323. </div>
  324. )
  325. }
  326. // 数字
  327. const numsFormat = function (data) {
  328. return data || data == 0 ? data : '--'
  329. }
  330. const arr = [
  331. { title: '', field: '', key: '0', width: 20, type: 'checkbox', align: 'center' },
  332. { title: '序号', field: 'no', key: '1', width: 30, align: 'center', operationColumn: false },
  333. {
  334. title: '产品编码',
  335. field: 'productCode',
  336. key: '2',
  337. align: 'left',
  338. width: 100,
  339. operationColumn: false,
  340. renderBodyCell: ({ row, column, rowIndex }, h) => {
  341. return (
  342. <div>
  343. <span style="padding-right: 10px;">{row.productEntity.code}</span>
  344. {row.promotionFlag.indexOf('GIFT') >= 0 ? <a-badge count="促" numberStyle={{ backgroundColor: '#52c41a', zoom: '0.7' }}/> : ''}
  345. {row.promotionFlag.indexOf('GATE') >= 0 ? <a-badge count="槛" numberStyle={{ backgroundColor: '#108ee9', zoom: '0.7' }}/> : ''}
  346. {row.promotionFlag.indexOf('REGULAR') >= 0 ? <a-badge count="正" numberStyle={{ backgroundColor: '#ff5500', zoom: '0.7' }}/> : ''}
  347. {row.promotionFlag.indexOf('DISCOUNT') >= 0 ? <a-badge count="特" numberStyle={{ backgroundColor: '#faad14', zoom: '0.7' }}/> : ''}
  348. {row.borrowFlag == '1' ? <a-badge count="累" numberStyle={{ backgroundColor: '#aa55ff', zoom: '0.7' }}/> : ''}
  349. {Number(row.stockQty || 0) < Number(row.unpushedQty || 0) && row.borrowFlag != '1' ? <a-badge count="缺" numberStyle={{ zoom: '0.7' }}/> : ''}
  350. </div>
  351. )
  352. }
  353. },
  354. {
  355. title: '产品名称',
  356. field: 'productName',
  357. key: '3',
  358. width: 150,
  359. align: 'left',
  360. operationColumn: false,
  361. ellipsis: { showTitle: true },
  362. renderBodyCell: ({ row, column, rowIndex }, h) => {
  363. return (
  364. <div class="ellipsisCon">
  365. <a-tooltip placement="rightBottom">
  366. <template slot="title">
  367. <span>{ row.productEntity.name || '--' }</span>
  368. </template>
  369. <span class="ellipsisText">{ row.productEntity.name || '--' }</span>
  370. </a-tooltip>
  371. </div>
  372. )
  373. }
  374. },
  375. {
  376. title: '规则数量',
  377. field: 'rulesNums',
  378. key: '4',
  379. width: 50,
  380. align: 'center',
  381. operationColumn: false,
  382. renderBodyCell: ({ row, column, rowIndex }, h) => {
  383. return (
  384. row.promoRuleSnList
  385. ? <a-popover placement="right">
  386. <template slot="content">
  387. {row.promoRuleSnList.map(item => {
  388. return (
  389. <div
  390. id={'salesEdit-gzitem-' + row.id}
  391. title="点击查看详情"
  392. style="padding:5px 0;cursor: pointer;"
  393. onClick={() => _this.showRuleDetail(item)}
  394. >{ _this.activeRuleFilter(item, row) }</div>
  395. )
  396. })}
  397. </template>
  398. <a-button type="link" id={'salesEdit-gzqty-' + row.id} size="small" class="button-info">{row.promoRuleNum}<span style="zoom:0.6;color: #666;">个∨</span></a-button>
  399. </a-popover> : '--'
  400. )
  401. } },
  402. { title: '起订量', field: 'promoUnit', key: '5', width: 60, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return (row.borrowFlag != '1' ? (row[column.field] || '--') : '--') } },
  403. {
  404. title: '销售数量',
  405. field: 'salesNums',
  406. key: '6',
  407. width: 80,
  408. align: 'center',
  409. operationColumn: false,
  410. renderBodyCell: ({ row, column, rowIndex }, h) => {
  411. return (
  412. !(row.promotionFlag.indexOf('GIFT') >= 0 && row.sameGiteFlag == '1') && row.borrowFlag != '1'
  413. ? <a-input-number
  414. id={'salesEdit-qty-' + row.id}
  415. size="small"
  416. style="width: 100%;"
  417. vModel={row.qty}
  418. precision={0}
  419. min={1}
  420. max={99999999}
  421. placeholder="请输入"
  422. onBlur={(e) => _this.onCellBlur(e.target.value, row)}
  423. />
  424. : <span>{ row.qty }</span>
  425. )
  426. }
  427. },
  428. {
  429. title: '库存',
  430. field: 'stockQty',
  431. width: 80,
  432. key: '7',
  433. align: 'center',
  434. operationColumn: false,
  435. renderBodyCell: ({ row, column, rowIndex }, h) => {
  436. return (
  437. (row.stockQty || row.stockQty == 0) && row.borrowFlag != '1'
  438. ? <div>
  439. {
  440. Number(row.stockQty) < Number(row.unpushedQty)
  441. ? <p style="margin: 0;">{ row.stockQty }(<span class="redStyle">缺{ Number(row.unpushedQty || 0) - Number(row.stockQty || 0) }</span>)</p>
  442. : <p style="margin: 0;">{ row.stockQty }</p>
  443. }
  444. </div>
  445. : <span>--</span>
  446. )
  447. }
  448. },
  449. {
  450. title: '出库仓库',
  451. field: 'warehouseBox',
  452. width: 80,
  453. key: '8',
  454. align: 'center',
  455. operationColumn: false,
  456. renderBodyCell: ({ row, column, rowIndex }, h) => {
  457. return (
  458. row.borrowFlag != '1'
  459. ? <a-select
  460. id={'salesEdit-warehouse-' + row.id}
  461. size="small"
  462. style="width:100%;"
  463. placeholder="请选择仓库"
  464. vModel={row.warehouseSn}
  465. showSearch={true}
  466. onChange={() => _this.handleWarehouseBox(row)}
  467. mode="default"
  468. filter-option={_this.filterOption}>
  469. {
  470. _this.warehouseDataList.map(item => {
  471. return <a-select-option key={item.warehouseSn} value={item.warehouseSn}>{ item.name }</a-select-option>
  472. })
  473. }
  474. </a-select> : <span>{ row.warehouseName }</span>
  475. )
  476. }
  477. },
  478. { title: '单位', field: 'productOrigUnit', width: 50, key: 'unit', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row.productEntity.unit || '--' } },
  479. {
  480. title: '操作',
  481. field: 'action',
  482. width: 80,
  483. key: 'action',
  484. align: 'center',
  485. fixed: 'right',
  486. operationColumn: false,
  487. // sameGiteFlag 是否正促一致
  488. renderBodyCell: ({ row, column, rowIndex }, h) => {
  489. return (
  490. <div>
  491. {
  492. row.promotionFlag.indexOf('GIFT') < 0 && row.borrowFlag != '1'
  493. ? <a-button
  494. id={'salesEdit-upactive-' + row.id}
  495. size="small"
  496. type="link"
  497. disabled={_this.delLoading}
  498. class="button-primary"
  499. onClick={() => _this.handleUpdateActive(row)}
  500. >换促销</a-button> : ''
  501. }
  502. {
  503. !(row.promotionFlag.indexOf('GIFT') >= 0 && row.sameGiteFlag == '1')
  504. ? <a-button
  505. id={'salesEdit-del-' + row.id}
  506. size="small"
  507. type="link"
  508. disabled={_this.delLoading}
  509. class="button-error"
  510. onClick={() => _this.handleDel(row)}
  511. >删除</a-button> : '--'
  512. }
  513. </div>
  514. )
  515. }
  516. }
  517. ]
  518. // 售价权限
  519. if (_this.$hasPermissions('B_salesEdit_salesPrice')) {
  520. arr.splice(4, 0, {
  521. title: '售价(原价)',
  522. field: 'price',
  523. width: 100,
  524. key: 'price',
  525. align: 'right',
  526. operationColumn: false,
  527. renderBodyCell: ({ row, column, rowIndex }, h) => { return discountPriceFormat(row, row[column.field], h) }
  528. })
  529. arr.splice(5, 0, { title: '价格级别', field: 'priceLevelDictValue', width: 60, key: 'priceLevel', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } })
  530. if (_this.showStockCol) {
  531. arr.splice(10, 0, { title: '第三方库存', field: 'thirdStockQty', key: 'thirdStockQty', width: 60, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } })
  532. }
  533. arr.splice((_this.showStockCol ? 11 : 10), 0, { title: '售价小计', field: 'totalAmount', key: 'totalAmount', width: 60, align: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return priceFormat(row[column.field]) } })
  534. } else {
  535. if (_this.showStockCol) {
  536. arr.splice(8, 0, { title: '第三方库存', field: 'thirdStockQty', key: 'thirdStockQty', width: 60, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } })
  537. }
  538. }
  539. return arr
  540. }
  541. },
  542. watch: {
  543. salesBillSn (newValue, oldValue) {
  544. this.resetSearchForm()
  545. },
  546. salesPromoSnSet (newValue, oldValue) {
  547. this.getTableData()
  548. this.clearTableSelect()
  549. },
  550. spinning (a, b) {
  551. if (a) {
  552. this.$emit('spinning', a)
  553. }
  554. }
  555. },
  556. methods: {
  557. // 选择单元格
  558. selectedRowChange ({ row, isSelected, selectedRowKeys }) {
  559. this.selectedRowKeys = selectedRowKeys
  560. },
  561. // 全选行
  562. selectedAllChange ({ isSelected, selectedRowKeys }) {
  563. this.selectedRowKeys = selectedRowKeys
  564. },
  565. // 获取表格数据
  566. getTableData () {
  567. this.disabled = true
  568. this.spinning = true
  569. this.queryParam.salesBillSn = this.salesBillSn || ''
  570. this.queryParam.salesPromoSnSet = this.salesPromoSnSet || []
  571. salesDetailExtPromoList(Object.assign(this.queryParam, {
  572. showStock: true
  573. // promoFlag: this.detailData.promoFlag
  574. })).then(res => {
  575. let data = []
  576. if (res.status == 200) {
  577. data = res.data
  578. const no = 0
  579. for (var i = 0; i < data.length; i++) {
  580. data[i].no = no + i + 1
  581. data[i].qtyBackups = data[i].qty
  582. data[i].productUnit = data[i].productEntity && data[i].productEntity.unit
  583. // 禁用选框
  584. if (data[i].promotionFlag.indexOf('GIFT') >= 0 && !!data[i].salesPromoDetailParentSn) {
  585. this.disableSelectedRowKeys.push(data[i].id)
  586. }
  587. }
  588. this.dataSource = data
  589. } else {
  590. this.dataSource = []
  591. }
  592. this.disabled = false
  593. this.spinning = false
  594. })
  595. },
  596. // 参与规则名称
  597. activeRuleFilter (val, data) {
  598. const row = this.activeList.length && this.activeList.find(item => item.promoRuleSn == val)
  599. const rule = data.salesPromoDetailList.find(item => item.promoRuleSn == val)
  600. return row ? (row.promotionRule.promotionRuleTypeDictValue + '-' + row.promotion.description + '(' + row.promotionRule.description + ')') + (data.borrowFlag != 1 ? ',起订量:' + rule.promoUnit : '') : ''
  601. },
  602. // 查看参与规则详情
  603. showRuleDetail (promoRuleSn) {
  604. this.$emit('showRuleDetail', promoRuleSn)
  605. },
  606. // 仓库下拉列表筛选
  607. filterOption (input, option) {
  608. return (
  609. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  610. )
  611. },
  612. // 仓库列表加载完成
  613. warehouseLoad (sn, list) {
  614. this.warehouseDataList = list
  615. },
  616. // 显示查询条件
  617. showSearch () {
  618. this.showSearchBox = !this.showSearchBox
  619. },
  620. // 查询第三方库存
  621. searchThreeStockOk () {
  622. this.resetSearchForm()
  623. this.showStockCol = true
  624. },
  625. // 表格选中项
  626. rowSelectionFun (obj) {
  627. this.rowSelectionInfo = obj || null
  628. },
  629. // 选择产品分类
  630. changeProductType (val, opt) {
  631. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  632. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  633. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  634. },
  635. // 重置查询
  636. resetSearchForm (flag) {
  637. this.queryParam.productCode = ''
  638. this.queryParam.productName = ''
  639. this.queryParam.warehouseSn = undefined
  640. this.queryParam.productBrandSn = undefined
  641. this.queryParam.productTypeSn1 = ''
  642. this.queryParam.productTypeSn2 = ''
  643. this.queryParam.productTypeSn3 = ''
  644. this.queryParam.borrowFlag = undefined
  645. this.queryParam.promoProductClz = undefined
  646. this.queryParam.unitFlag = undefined
  647. this.productType = []
  648. this.rowSelectionInfo = null
  649. this.getTableData()
  650. this.clearTableSelect()
  651. },
  652. // 查询产品,不重置
  653. searchProduct () {
  654. this.getTableData()
  655. },
  656. clearTableSelect () {
  657. this.disableSelectedRowKeys = []
  658. this.selectedRowKeys = []
  659. },
  660. // 保存添加的产品到销售列表
  661. saveNewProduct (row, promo, promoProductClz) {
  662. // 防止多次添加产品
  663. if (this.isInster) { return }
  664. this.$message.loading('正在添加产品...', 1)
  665. this.isInster = true
  666. this.spinning = true
  667. const params = {
  668. salesPromoSn: promo.salesPromoSn,
  669. promoRuleSn: promo.promoRuleSn,
  670. promoSn: promo.promoSn,
  671. promoProductClz: promoProductClz,
  672. packQty: row.productPackQty,
  673. productSn: row.productSn,
  674. showCost: row.lastStockCost,
  675. price: row.productPrice,
  676. origPrice: row.origPrice,
  677. promotionGiftsAmount: 0,
  678. usePromotionGiftsAmount: 0,
  679. qty: row.salesNums,
  680. salesBillSn: this.detailData.salesBillSn,
  681. salesBillNo: this.detailData.salesBillNo,
  682. purchaseBillSn: this.detailData.purchaseBillSn,
  683. purchaseBillNo: this.detailData.purchaseBillNo,
  684. priceLevel: row.priceLevel,
  685. stockSn: row.stockSn,
  686. promotableFlag: row.isJoinActivityProduct || 0, // 可促销标记 有活动的传1,没活动的传0
  687. promotionFlag: 0, // 促销标记 正品传0,促销品传1
  688. warehouseSn: row.warehouseSn
  689. }
  690. salesDetailInsert(params).then(res => {
  691. if (res.status == 200) {
  692. this.$message.success('产品添加成功', 2.5)
  693. this.resetSearchForm(true)
  694. this.$emit('refash', 'promo', 'add')
  695. } else {
  696. this.$emit('error', 'promo', 'add')
  697. }
  698. this.spinning = false
  699. this.isInster = false
  700. }).catch(err => {
  701. this.$emit('error', 'promo', 'add')
  702. this.isInster = false
  703. this.spinning = false
  704. })
  705. },
  706. // 累计产品到活动
  707. accumulateProduct (chooseData, promo, promoProductClz) {
  708. // 防止多次添加产品
  709. if (this.isInster) { return }
  710. this.$message.loading('正在添加产品...', 1)
  711. this.isInster = true
  712. this.spinning = true
  713. const params = {
  714. salesPromoSn: promo.salesPromoSn,
  715. salesBillSn: promo.salesBillSn,
  716. salesBillDetailList: chooseData,
  717. promoProductClz
  718. }
  719. salesDetailInsertBatchBorrow(params).then(res => {
  720. this.spinning = false
  721. this.isInster = false
  722. if (res.status == 200) {
  723. this.$message.success('累计产品添加成功', 2.5)
  724. this.resetSearchForm(true)
  725. this.$emit('refash', 'borrow', 'add')
  726. } else {
  727. this.$emit('error', 'borrow', 'add')
  728. }
  729. }).catch(err => {
  730. this.$emit('error', 'borrow', 'add')
  731. this.isInster = false
  732. this.spinning = false
  733. })
  734. },
  735. // 批量取消出现产品
  736. handleBatchCancelActive () {
  737. const _this = this
  738. if (this.selectTotal == 0) {
  739. _this.$message.warning('请先选择要批量取消的产品!')
  740. return
  741. }
  742. const len = this.selectedRowKeys.length
  743. const rowSelect = this.dataSource.filter(item => this.selectedRowKeys.includes(item.id))
  744. // 判断是否全部为赠品
  745. const obj = []
  746. const gift = []
  747. rowSelect && rowSelect.map(item => {
  748. // 赠品
  749. if (item.promotionFlag.indexOf('GIFT') >= 0) {
  750. gift.push(item.productCode)
  751. } else {
  752. // 非赠品
  753. obj.push(item.salesBillDetailSn)
  754. }
  755. })
  756. // 如果全部是赠品,不能转为正常产品
  757. if (gift.length == len) {
  758. this.$info({
  759. title: '提示',
  760. content: '所选全部为赠品,其不能转为正常产品!',
  761. centered: true,
  762. okText: '知道了'
  763. })
  764. return
  765. }
  766. this.$confirm({
  767. title: '提示',
  768. content: '已选产品' + len + '项,' + (gift.length ? '其中包含赠品' + gift.join(',') + '(赠品不能转正常产品),确认要继续批量取消促销转为正常产品吗?' : '确认要批量取消促销转为正常产品吗?'),
  769. centered: true,
  770. onOk () {
  771. _this.spinning = true
  772. const params = {
  773. salesBillDetailSnList: obj,
  774. salesBillSn: _this.salesBillSn
  775. }
  776. // 更换活动
  777. _this.$emit('upActive', params, 1)
  778. }
  779. })
  780. },
  781. // 删除全部产品
  782. handleBatchDelAll () {
  783. const _this = this
  784. if (_this.dataSource.length == 0) {
  785. _this.$message.warning('暂无可删除的产品!')
  786. return
  787. }
  788. this.$confirm({
  789. title: '提示',
  790. content: '确认要删除全部已选活动产品吗?',
  791. centered: true,
  792. onOk () {
  793. _this.spinning = true
  794. deletePromoAll({ salesBillSn: _this.salesBillSn }).then(res => {
  795. if (res.status == 200) {
  796. _this.searchProduct()
  797. _this.$emit('refash', 'promo', 'batchDel')
  798. _this.$message.success(res.message)
  799. }
  800. _this.spinning = false
  801. })
  802. }
  803. })
  804. },
  805. // 批量删除已选产品
  806. handleBatchDel () {
  807. const _this = this
  808. if (this.selectTotal == 0) {
  809. _this.$message.warning('请先选择要批量删除产品!')
  810. return
  811. }
  812. const selectedRows = this.dataSource.filter(item => this.selectedRowKeys.includes(item.id))
  813. const obj = selectedRows ? selectedRows.map(item => item.salesBillDetailSn) : []
  814. this.$confirm({
  815. title: '提示',
  816. content: '已选产品' + obj.length + '项,确认要批量删除吗?',
  817. centered: true,
  818. onOk () {
  819. _this.spinning = true
  820. salesDetailBatchDel({
  821. salesBillSn: _this.salesBillSn,
  822. salesBillDetailSnList: obj
  823. }).then(res => {
  824. if (res.status == 200) {
  825. _this.searchProduct()
  826. _this.clearTableSelect()
  827. _this.$emit('refash', 'promo', 'batchDel')
  828. _this.$message.success(res.message)
  829. }
  830. _this.spinning = false
  831. })
  832. }
  833. })
  834. },
  835. // 设置单个出库仓库
  836. handleWarehouseBox (row) {
  837. const snArr = [row.salesBillDetailSn]
  838. const ajax_data = {
  839. warehouseSn: row.warehouseSn,
  840. salesBillDetailSnList: snArr,
  841. salesBillSn: this.salesBillSn,
  842. allFlag: false,
  843. salesPromoDetailSnSet: row.salesPromoDetailList ? [row.salesPromoDetailList[0].salesPromoDetailSn] : undefined
  844. }
  845. this.setWarehouseInfo(ajax_data)
  846. },
  847. // 选择仓库确认
  848. chooseWarehouseOk (sn) {
  849. const _this = this
  850. const selectedRows = _this.dataSource.filter(item => _this.selectedRowKeys.includes(item.id))
  851. const obj = selectedRows ? selectedRows.map(item => item.salesBillDetailSn) : []
  852. const mergedArr = _this.getSalesPromoSnList(obj && obj.length > 0 ? selectedRows : _this.dataSource)
  853. const ajaxData = {
  854. warehouseSn: sn,
  855. salesBillDetailSnList: obj,
  856. salesBillSn: _this.salesBillSn,
  857. allFlag: obj && obj.length === 0, // 设置全部参数
  858. salesPromoDetailSnSet: mergedArr
  859. }
  860. _this.setWarehouseInfo(ajaxData)
  861. },
  862. // 筛选salesPromoSnSet值
  863. getSalesPromoSnList (arr) {
  864. // 借助reduce方法和Set来合并salesPromoDetailSn值并去重
  865. const mergedAndUniqueVals = arr.reduce((acc, item) => {
  866. // 遍历当前项的salesPromoDetailList数组
  867. item.salesPromoDetailList.forEach(subItem => {
  868. // 将每个subItem的salesPromoDetailSn添加到累加器Set中
  869. acc.add(subItem.salesPromoDetailSn)
  870. })
  871. // 返回累加器Set供下一次迭代使用
  872. return acc
  873. }, new Set())
  874. const resultArr = Array.from(mergedAndUniqueVals)
  875. return resultArr
  876. },
  877. // 更改仓库信息
  878. setWarehouseInfo (data) {
  879. const _this = this
  880. _this.spinning = true
  881. updateWarehouse(data).then(res => {
  882. if (res.status == 200) {
  883. _this.$message.success(res.message)
  884. _this.$emit('refash', 'promo', 'update')
  885. }
  886. _this.openWarehouseModal = false
  887. _this.searchProduct()
  888. _this.clearTableSelect()
  889. _this.spinning = false
  890. })
  891. },
  892. // 更多操作下拉菜单
  893. handleMenuClick (e) {
  894. const _this = this
  895. if (e.key == 0) { // 部分仓库设置
  896. if (_this.selectTotal == 0) {
  897. _this.$message.warning('请先选择要批量设置的产品!')
  898. } else {
  899. _this.warehouseTit = '部分仓库设置'
  900. _this.openWarehouseModal = true
  901. }
  902. } else if (e.key == 1) { // 删除已选项
  903. this.handleBatchDel()
  904. } else if (e.key == 3) { // 全部仓库设置
  905. if (_this.dataSource.length == 0) {
  906. _this.$message.warning('暂无可设置的产品!')
  907. return
  908. }
  909. _this.clearTableSelect()
  910. _this.warehouseTit = '全部仓库设置'
  911. _this.openWarehouseModal = true
  912. } else if (e.key == 4) { // 批量取消促销
  913. _this.handleBatchCancelActive()
  914. } else { // 全部删除
  915. _this.clearTableSelect()
  916. _this.handleBatchDelAll()
  917. }
  918. },
  919. // 打开换促销活动列表选项
  920. handleUpdateActive (record) {
  921. this.$refs.updateActive.getActiveList({
  922. productSn: record.productSn,
  923. salesBillSn: this.salesBillSn,
  924. salesBillDetailSn: record.salesBillDetailSn
  925. }, record)
  926. this.openUpActiveModal = true
  927. },
  928. // 已选产品数量修改
  929. onCellBlur (val, record) {
  930. const _this = this
  931. // 光标移出,值发生改变再调用编辑接口
  932. if (val && val != record.qtyBackups) {
  933. _this.spinning = true
  934. salesDetailUpdateQty({
  935. salesBillDetailSn: record.salesBillDetailSn,
  936. qty: record.qty,
  937. salesBillSn: _this.salesBillSn
  938. }).then(res => {
  939. if (res.status == 200) {
  940. _this.$emit('refash', 'promo', 'update')
  941. _this.$message.success(res.message)
  942. }
  943. _this.searchProduct()
  944. _this.spinning = false
  945. })
  946. } else {
  947. record.qty = record.qtyBackups
  948. }
  949. },
  950. // 删除产品
  951. handleDel (row) {
  952. const _this = this
  953. this.$confirm({
  954. title: '提示',
  955. content: '确认要删除吗?',
  956. centered: true,
  957. closable: true,
  958. onOk () {
  959. _this.delLoading = true
  960. _this.spinning = true
  961. salesDetailDel({ salesBillDetailSn: row.salesBillDetailSn, salesBillSn: _this.salesBillSn }).then(res => {
  962. if (res.status == 200) {
  963. _this.searchProduct()
  964. _this.$emit('refash', 'promo', 'del')
  965. _this.$message.success(res.message)
  966. }
  967. _this.delLoading = false
  968. _this.spinning = false
  969. })
  970. }
  971. })
  972. },
  973. // 确定更换促销活动
  974. async upActiveOk (salesPromoSnList, editRow) {
  975. const params = {
  976. salesBillDetailSn: editRow.salesBillDetailSn,
  977. salesBillSn: this.salesBillSn,
  978. priceLevel: editRow.priceLevel,
  979. salesPromoSnList: salesPromoSnList
  980. }
  981. // 更换活动
  982. this.$emit('upActive', params, 1)
  983. },
  984. // 更换活动成功
  985. upAcitveSuccess () {
  986. this.spinning = false
  987. this.$refs.updateActive.confirmLoading = false
  988. this.openUpActiveModal = false
  989. this.clearTableSelect()
  990. this.searchProduct()
  991. }
  992. }
  993. }
  994. </script>
  995. <style lang="less">
  996. .empty-data2{
  997. color: #999;
  998. text-align: center;
  999. padding: 20px;
  1000. position: absolute;
  1001. bottom: 50px;
  1002. width: 100%;
  1003. }
  1004. .table-header-cell-center{
  1005. text-align: center!important;
  1006. }
  1007. .ant-input-number-sm input{
  1008. text-align: center;
  1009. }
  1010. </style>