productList.vue 32 KB

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