productList.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. <template>
  2. <div>
  3. <div class="table-page-search-wrapper" v-show="showDescBox">
  4. <a-descriptions :column="4" v-if="descDetail">
  5. <a-descriptions-item label="促销类型">
  6. {{ descDetail.promotionRuleTypeDictValue||'--' }}
  7. </a-descriptions-item>
  8. <a-descriptions-item label="促销门槛" span="3">
  9. <div v-if="descDetail.gateFlag === '1'">
  10. <span v-if="descDetail.gateType==='RATIO_AMOUNT'">
  11. 购买门槛产品金额{{ descDetail.gateAmount*100 }}%作为配额
  12. </span>
  13. <span v-else-if="descDetail.gateType==='MIN_AMOUNT'">
  14. 购买门槛产品满最低金额{{ descDetail.gateAmount }}不限制配额。
  15. </span>
  16. <span v-else>购买满{{ descDetail.gateAmount }}元门槛产品,可使用 {{ descDetail.quotaAmount }}元配额,采购规则中的正价商品</span>
  17. </div>
  18. <span v-else>--</span>
  19. </a-descriptions-item>
  20. <a-descriptions-item label="促销规则">
  21. <div v-if="descDetail.promotionRuleType == 'BUY_PROD_GIVE_PROD'">
  22. 购买满{{ descDetail.regularQty }}个正价产品,送{{ descDetail.promotionQty }}个促销产品
  23. </div>
  24. <div v-else-if="descDetail.promotionRuleType == 'BUY_PROD_GIVE_MONEY'">
  25. 购买满{{ descDetail.regularAmount }}元正价产品,送{{ descDetail.giveAmount }}元促销品采购额
  26. </div>
  27. <div v-else>
  28. 特价产品
  29. </div>
  30. </a-descriptions-item>
  31. <a-descriptions-item label="显示正价产品款数">
  32. {{ descDetail.restrictCategory||'--' }}
  33. </a-descriptions-item>
  34. <a-descriptions-item label="订单起订金额">
  35. {{ descDetail.minOrderAmount||'--' }}
  36. </a-descriptions-item>
  37. <a-descriptions-item label="活动经费上线">
  38. {{ descDetail.upperLimitAmount||'--' }}
  39. </a-descriptions-item>
  40. </a-descriptions>
  41. </div>
  42. <!-- 筛选条件 -->
  43. <div class="table-page-search-wrapper" style="margin:0" v-show="showSearchBox">
  44. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  45. <a-row :gutter="15">
  46. <a-col :md="4" :sm="24">
  47. <a-form-item label="出库仓库" prop="warehouseSn">
  48. <chooseWarehouse ref="warehouse" v-model="queryParam.warehouseSn" @load="warehouseLoad"></chooseWarehouse>
  49. </a-form-item>
  50. </a-col>
  51. <a-col :md="4" :sm="24">
  52. <a-form-item label="产品编码" prop="productCode">
  53. <a-input id="salesEdit-productCode" v-model.trim="queryParam.productCode" placeholder="请输入产品编码" allowClear />
  54. </a-form-item>
  55. </a-col>
  56. <a-col :md="4" :sm="24">
  57. <a-form-item label="产品名称" prop="productName">
  58. <a-input id="salesEdit-productName" v-model.trim="queryParam.productName" placeholder="请输入产品名称" allowClear />
  59. </a-form-item>
  60. </a-col>
  61. <a-col :md="4" :sm="24">
  62. <a-form-item label="品牌">
  63. <ProductBrand id="salesEdit-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  64. </a-form-item>
  65. </a-col>
  66. <a-col :md="4" :sm="24">
  67. <a-form-item label="产品分类">
  68. <productTypeAll placeholder="请选择产品分类" @change="changeProductType" v-model="productType" id="salesEdit-productType"></productTypeAll>
  69. </a-form-item>
  70. </a-col>
  71. <a-col :md="4" :sm="24" style="margin-bottom: 10px;">
  72. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="salesEdit-refresh">查询</a-button>
  73. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="salesEdit-reset">重置</a-button>
  74. </a-col>
  75. </a-row>
  76. </a-form>
  77. </div>
  78. <div class="table-page-search-wrapper">
  79. <a-row :gutter="15" type="flex" justify="space-between" align="middle">
  80. <a-col :md="12" :sm="24" style="text-align:left;">
  81. <a-dropdown>
  82. <a-menu slot="overlay" @click="handleMenuClick">
  83. <a-menu-item key="0" :disabled="disablePromo">
  84. 仓库设置
  85. </a-menu-item>
  86. <a-menu-item key="1">
  87. 删除已选项
  88. </a-menu-item>
  89. <a-menu-item key="2">
  90. 全部删除
  91. </a-menu-item>
  92. </a-menu>
  93. <a-button
  94. type="default"
  95. class="button-info"
  96. > 批量操作 <a-icon type="down" /> </a-button>
  97. </a-dropdown>
  98. <span v-if="selectTotal" style="margin-left:5px;">已选{{ selectTotal }}项</span>
  99. </a-col>
  100. <a-col :md="12" :sm="24" style="text-align:right;">
  101. <a-button
  102. type="link"
  103. class="button-info"
  104. @click="showSearchBox=!showSearchBox" ><a-icon type="search"/> 筛选</a-button>
  105. <a-dropdown :disabled="disablePromo">
  106. <a-menu slot="overlay" @click="handleImportClick">
  107. <a-menu-item key="GATE">
  108. 导入门槛产品
  109. </a-menu-item>
  110. <a-menu-item key="REGULAR">
  111. 导入正价产品
  112. </a-menu-item>
  113. <a-menu-item key="GIFT">
  114. 导入促销产品
  115. </a-menu-item>
  116. </a-menu>
  117. <a-button
  118. type="link"
  119. :class="disablePromo?'button-gray':'button-info'"
  120. > 导入产品 <a-icon type="down" /> </a-button>
  121. </a-dropdown>
  122. <a-button
  123. type="link"
  124. :class="disablePromo?'button-gray':'button-info'"
  125. :disabled="disablePromo"
  126. @click="openCpModal"><a-icon type="plus" /> 添加产品</a-button>
  127. </a-col>
  128. </a-row>
  129. </div>
  130. <!-- 已选配件列表 -->
  131. <s-table
  132. class="sTable"
  133. ref="table"
  134. size="small"
  135. :rowKey="(record) => record.id"
  136. :columns="columns"
  137. :data="loadData"
  138. :row-selection="{ columnWidth: 40 }"
  139. @rowSelection="rowSelectionFun"
  140. :pageSize="10"
  141. bordered>
  142. <!-- 产品编码 -->
  143. <template slot="productCode" slot-scope="text, record">
  144. <span style="padding-right: 15px;">{{ text }}</span>
  145. <a-badge count="促" v-if="record.promotionFlag=='GIFT'" :number-style="{ backgroundColor: '#52c41a', zoom:'80%' }"></a-badge>
  146. <!-- <a-badge count="正" v-if="record.promotionFlag=='REGULAR'" :number-style="{ backgroundColor: '#108ee9', zoom:'80%' }"></a-badge> -->
  147. <a-badge count="特" v-if="record.promotionFlag=='DISCOUNT'" :number-style="{ backgroundColor: '#faad14', zoom:'80%' }"></a-badge>
  148. <a-badge count="缺" v-if="Number(record.stockQty||0) < Number(record.unpushedQty||0)" :number-style="{ zoom:'80%' }"></a-badge>
  149. </template>
  150. <!-- 产品名称 -->
  151. <template slot="productName" slot-scope="text, record">
  152. <div class="ellipsisCon">
  153. <a-tooltip placement="rightBottom">
  154. <template slot="title">
  155. <span>{{ text }}</span>
  156. </template>
  157. <span class="ellipsisText">{{ text }}</span>
  158. </a-tooltip>
  159. <a-badge :number-style="{ backgroundColor: '#52c41a' }" count="活动" v-if="record.promotableFlag == 1"></a-badge>
  160. </div>
  161. </template>
  162. <!-- 促销价 -->
  163. <template slot="discountPrice" slot-scope="text, record">
  164. <span>{{ record.discountedPrice }}</span>
  165. ({{ record.discountRate }}%)
  166. </template>
  167. <!-- 销售数量 -->
  168. <template slot="salesNums" slot-scope="text, record">
  169. <a-input-number
  170. id="salesEdit-qty"
  171. size="small"
  172. v-model="record.qty"
  173. :precision="0"
  174. :min="1"
  175. :max="999999"
  176. placeholder="请输入"
  177. @blur="e => onCellBlur(e.target.value, record)"
  178. style="width: 100%;" />
  179. </template>
  180. <!-- 当前库存 -->
  181. <template slot="stockQty" slot-scope="text, record">
  182. <div v-if="record.stockQty || record.stockQty==0">
  183. <p style="margin: 0;" v-if="Number(record.stockQty) < Number(record.unpushedQty)">{{ record.stockQty }}(<span class="redStyle">缺{{ Number(record.unpushedQty||0) - Number(record.stockQty||0) }}</span>)</p>
  184. <p style="margin: 0;" v-else>{{ record.stockQty }}</p>
  185. </div>
  186. <span v-else>--</span>
  187. </template>
  188. <!-- 出库仓库 -->
  189. <template slot="warehouseBox" slot-scope="text, record">
  190. <a-select
  191. size="small"
  192. style="width:100%;"
  193. placeholder="请选择仓库"
  194. v-model="record.warehouseSn"
  195. :showSearch="true"
  196. @change="handleWarehouseBox(record)"
  197. mode="default"
  198. :filter-option="filterOption">
  199. <a-select-option v-for="item in warehouseDataList" :key="item.warehouseSn" :value="item.warehouseSn">{{ item.name }}</a-select-option>
  200. </a-select>
  201. </template>
  202. <!-- 操作 -->
  203. <template slot="action" slot-scope="text, record">
  204. <a-button
  205. size="small"
  206. type="link"
  207. :loading="delLoading"
  208. class="button-error"
  209. @click="handleDel(record)"
  210. >删除</a-button>
  211. <a-button
  212. size="small"
  213. type="link"
  214. :loading="delLoading"
  215. class="button-primary"
  216. @click="handleUpdateActive(record)"
  217. >换促销</a-button>
  218. </template>
  219. <template slot="footer" slot-scope="currentPageData">
  220. <!-- 总计 -->
  221. <a-alert type="info" banner :showIcon="false">
  222. <div slot="message" class="alert-bar">
  223. <div>
  224. {{ countData&&countData.remarks }}
  225. </div>
  226. <div style="display: flex;">
  227. <div>
  228. 款数:<strong>{{ countData&&(countData.totalCategory || countData.totalCategory==0) ? countData.totalCategory : '--' }}</strong>
  229. </div>
  230. <div style="padding: 0 10px;">
  231. 数量:<strong>{{ countData&&(countData.totalQty || countData.totalQty==0) ? countData.totalQty : '--' }}</strong>
  232. </div>
  233. <div>
  234. <div v-if="$hasPermissions('B_salesEdit_salesPrice')">总金额:<strong>{{ countData&&(countData.totalAmount || countData.totalAmount==0) ? toThousands(countData.totalAmount) : '--' }}</strong></div>
  235. <div v-if="$hasPermissions('B_salesEdit_salesPrice')&&countData&&countData.lossAmount">优惠金额:<strong>{{ toThousands(countData.lossAmount) }}</strong></div>
  236. </div>
  237. </div>
  238. </div>
  239. </a-alert>
  240. </template>
  241. </s-table>
  242. <!-- 导入产品 -->
  243. <importGuideModal
  244. :openModal="openGuideModal"
  245. :params="{salesBillSn: $route.params.sn, salesPromoSn: promo.salesPromoSn}"
  246. :promoProductClz="promoProductClz"
  247. @close="closeGuideModel"
  248. @ok="hanldeImportOk" />
  249. <!-- 仓库设置 -->
  250. <setWarehouse :show="openWarehouseModal" @ok="chooseWarehouseOk" @cancel="openWarehouseModal=false"></setWarehouse>
  251. <!-- 换促销 -->
  252. <updateActiveModal ref="updateActive" :show="openUpActiveModal" @ok="upActiveOk" @cancel="openUpActiveModal=false"></updateActiveModal>
  253. </div>
  254. </template>
  255. <script>
  256. import { commonMixin } from '@/utils/mixin'
  257. import { STable, VSelect } from '@/components'
  258. import ImportGuideModal from './importGuideModal.vue'
  259. import setWarehouse from './setWarehouse.vue'
  260. import updateActiveModal from './updateActiveModal.vue'
  261. import chooseWarehouse from '@/views/common/chooseWarehouse'
  262. import ProductBrand from '@/views/common/productBrand.js'
  263. import productTypeAll from '@/views/common/productTypeAll.js'
  264. import {
  265. salesDetailList,
  266. salesPromoDetailCount,
  267. salesDetailInsert,
  268. salesDetailUpdateQty,
  269. salesDetailDel,
  270. salesDetailBatchDel,
  271. deleteAll,
  272. updateWarehouse,
  273. salesBatchInsert,
  274. } from '@/api/salesDetailNew'
  275. export default {
  276. name: 'ProductList',
  277. mixins: [commonMixin],
  278. components: {
  279. STable,
  280. VSelect,
  281. ImportGuideModal,
  282. chooseWarehouse,
  283. setWarehouse,
  284. ProductBrand,
  285. productTypeAll,
  286. updateActiveModal
  287. },
  288. props: {
  289. openModal: { // 弹框显示状态
  290. type: Boolean,
  291. default: false
  292. },
  293. newLoading: Boolean,
  294. detailData: {
  295. type: Object,
  296. default: function(){return null}
  297. },
  298. promo: {
  299. type: Object,
  300. default: function(){return null}
  301. },
  302. id: {
  303. type: String,
  304. default: ''
  305. },
  306. warehouseSn: {
  307. type: String,
  308. default: ''
  309. },
  310. salesBillSn: {
  311. type: String,
  312. default: ''
  313. }
  314. },
  315. data () {
  316. return {
  317. spinning: false,
  318. // 加载数据方法 必须为 Promise 对象
  319. loadData: parameter => {
  320. this.disabled = true
  321. this.queryParam.salesBillSn = this.salesBillSn || ''
  322. this.getCount()
  323. return salesDetailList(Object.assign(parameter, this.queryParam, {
  324. showStock: true,
  325. promoRuleSn: this.promo.promoRuleSn,
  326. promoSn: this.promo.promoSn,
  327. salesPromoSn: this.promo.salesPromoSn
  328. })).then(res => {
  329. let data
  330. if (res.status == 200) {
  331. data = res.data
  332. const no = (data.pageNo - 1) * data.pageSize
  333. for (var i = 0; i < data.list.length; i++) {
  334. data.list[i].no = no + i + 1
  335. data.list[i].qtyBackups = data.list[i].qty
  336. }
  337. this.disabled = false
  338. this.dataSource = data.list
  339. }
  340. return data
  341. })
  342. },
  343. showSearchBox: false,
  344. showDescBox: false,
  345. openWarehouseModal: false, // 打开仓库设置
  346. openGuideModal: false, // 导入产品引导
  347. delLoading: false,
  348. chooseDisabled: false,
  349. disabled: false, // 查询、重置按钮是否可操作
  350. queryParam: {
  351. warehouseSn: undefined,
  352. productCode: '',
  353. productName: '',
  354. productBrandSn: undefined,
  355. productTypeSn1: '', // 产品一级分类
  356. productTypeSn2: '', // 产品二级分类
  357. productTypeSn3: '' // 产品三级分类
  358. },
  359. productType: [],
  360. rowSelectionInfo: null,
  361. warehouseDataList: [],
  362. openUpActiveModal: false,
  363. descDetail: null,
  364. promoProductClz: null, // 活动产品分类
  365. disablePromo: false,
  366. countData: null
  367. }
  368. },
  369. computed: {
  370. selectTotal () {
  371. return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length || 0
  372. },
  373. columns () {
  374. const arr = [
  375. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  376. { title: '产品编码', dataIndex: 'productEntity.code', scopedSlots: { customRender: 'productCode' }, width: '13%', align: 'center' },
  377. { title: '产品名称', dataIndex: 'productEntity.name', scopedSlots: { customRender: 'productName' }, width: '20%', align: 'left' },
  378. { title: '起订量', dataIndex: 'unitQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  379. { title: '销售数量', scopedSlots: { customRender: 'salesNums' }, width: '8%', align: 'center' },
  380. { title: '库存', dataIndex: 'stockQty', scopedSlots: { customRender: 'stockQty' }, width: '8%', align: 'center' },
  381. { title: '出库仓库', scopedSlots: { customRender: 'warehouseBox' }, width: '15%', align: 'center' },
  382. { title: '单位', dataIndex: 'productEntity.unit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  383. // { title: '售价小计', dataIndex: 'totalAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  384. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  385. ]
  386. if (this.$hasPermissions('B_salesEdit_salesPrice')) { // 售价权限
  387. arr.splice(3, 0, { title: '售价', dataIndex: 'price', width: '8%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  388. // 如果是特价活动
  389. if(this.promo.promotionRule.promotionRuleType=='PROMO_PROD'){
  390. arr.splice(4, 0, { title: '促销价', dataIndex: 'discountPrice', width: '8%', align: 'right', scopedSlots: { customRender: 'discountPrice' }})
  391. }
  392. arr.splice(7, 0, { title: '售价小计', dataIndex: 'totalAmount', width: '8%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  393. }
  394. return arr
  395. }
  396. },
  397. watch: {
  398. salesBillSn(newValue, oldValue) {
  399. this.resetSearchForm()
  400. }
  401. },
  402. methods: {
  403. filterOption (input, option) {
  404. return (
  405. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  406. )
  407. },
  408. warehouseLoad(sn,list){
  409. this.warehouseDataList = list
  410. },
  411. showSearch(){
  412. this.showSearchBox = !this.showSearchBox
  413. },
  414. showDesc(descDetail){
  415. this.showDescBox = !this.showDescBox
  416. this.descDetail = descDetail
  417. },
  418. openCpModal(){
  419. this.$emit('openCpModal', 1, this.id)
  420. },
  421. // 表格选中项
  422. rowSelectionFun (obj) {
  423. this.rowSelectionInfo = obj || null
  424. },
  425. // 产品分类 change
  426. changeProductType (val, opt) {
  427. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  428. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  429. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  430. },
  431. // 禁用活动
  432. disableActive(){
  433. this.resetSearchForm()
  434. this.disablePromo = true
  435. },
  436. // 统计
  437. getCount(){
  438. salesPromoDetailCount(Object.assign(this.queryParam, {
  439. salesBillSn: this.salesBillSn,
  440. promoRuleSn: this.promo.promoRuleSn,
  441. promoSn: this.promo.promoSn,
  442. salesPromoSn: this.promo.salesPromoSn
  443. })).then(res => {
  444. if(res.status == 200){
  445. this.countData = res.data
  446. }
  447. })
  448. },
  449. // 重置
  450. resetSearchForm (flag) {
  451. this.queryParam.productCode = ''
  452. this.queryParam.productName = ''
  453. this.queryParam.warehouseSn = undefined
  454. this.queryParam.productBrandSn = undefined
  455. this.queryParam.productTypeSn1 = ''
  456. this.queryParam.productTypeSn2 = ''
  457. this.queryParam.productTypeSn3 = ''
  458. this.productType = []
  459. this.$refs.table.clearSelected()
  460. this.$refs.table.refresh(!!flag)
  461. },
  462. // 删除全部产品
  463. handleBatchDelAll () {
  464. const _this = this
  465. if (_this.dataSource.length == 0) {
  466. _this.$message.warning('暂无可删除的已选产品!')
  467. return
  468. }
  469. this.$confirm({
  470. title: '提示',
  471. content: '确认要删除全部已选产品吗?',
  472. centered: true,
  473. onOk () {
  474. _this.spinning = true
  475. deleteAll({ salesBillSn: _this.salesBillSn, salesPromoSn: _this.promo.salesPromoSn }).then(res => {
  476. if (res.status == 200) {
  477. _this.resetSearchForm(true)
  478. _this.$emit('insterOk','promo')
  479. _this.$message.success(res.message)
  480. }
  481. _this.spinning = false
  482. })
  483. }
  484. })
  485. },
  486. // 批量删除已选产品
  487. handleBatchDel () {
  488. const _this = this
  489. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  490. _this.$message.warning('请先选择要删除的产品后再进行批量操作!')
  491. return
  492. }
  493. const obj = []
  494. _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
  495. obj.push(item.salesBillDetailSn)
  496. })
  497. this.$confirm({
  498. title: '提示',
  499. content: '已选产品' + obj.length + '项,确认要批量删除吗?',
  500. centered: true,
  501. onOk () {
  502. _this.spinning = true
  503. salesDetailBatchDel({
  504. salesBillSn: _this.salesBillSn,
  505. salesPromoSn: _this.promo.salesPromoSn,
  506. salesBillDetailSnList: obj
  507. }).then(res => {
  508. if (res.status == 200) {
  509. _this.resetSearchForm(true)
  510. _this.$emit('insterOk','promo')
  511. _this.$message.success(res.message)
  512. }
  513. _this.spinning = false
  514. })
  515. }
  516. })
  517. },
  518. // 设置单个出库仓库
  519. handleWarehouseBox (row) {
  520. const snArr = [row.salesBillDetailSn]
  521. const ajax_data = {
  522. warehouseSn: row.warehouseSn,
  523. salesBillDetailSnList: snArr,
  524. salesBillSn: this.salesBillSn,
  525. salesPromoSn: this.promo.salesPromoSn
  526. }
  527. this.setWarehouseInfo(ajax_data)
  528. },
  529. chooseWarehouseOk (sn) {
  530. const _this = this
  531. const snArr = []
  532. _this.rowSelectionInfo.selectedRows.forEach(item => {
  533. snArr.push(item.salesBillDetailSn)
  534. })
  535. const ajax_data = {
  536. warehouseSn: sn,
  537. salesBillDetailSnList: snArr,
  538. salesBillSn: _this.salesBillSn,
  539. salesPromoSn: _this.promo.salesPromoSn
  540. }
  541. _this.setWarehouseInfo(ajax_data)
  542. },
  543. setWarehouseInfo (data) {
  544. const _this = this
  545. _this.spinning = true
  546. updateWarehouse(data).then(res => {
  547. if (res.status == 200) {
  548. _this.openWarehouseModal = false
  549. _this.resetSearchForm(true)
  550. _this.$message.success(res.message)
  551. }
  552. _this.$refs.table.refresh(true)
  553. _this.spinning = false
  554. })
  555. },
  556. handleMenuClick (e) {
  557. const _this = this
  558. if (e.key == 0) { // 仓库设置
  559. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  560. _this.$message.warning('请先选择要设置的产品!')
  561. } else {
  562. _this.openWarehouseModal = true
  563. }
  564. } else if (e.key == 1) { // 删除已选项
  565. this.handleBatchDel()
  566. } else {
  567. this.handleBatchDelAll()
  568. }
  569. },
  570. // 打开换促销活动列表选项
  571. handleUpdateActive(record){
  572. this.$refs.updateActive.getActiveList({
  573. productSn: record.productSn,
  574. salesBillSn: this.salesBillSn,
  575. promoRuleSn: this.promo.promoRuleSn
  576. },record)
  577. this.openUpActiveModal = true
  578. },
  579. // 已选产品 blur
  580. onCellBlur (val, record) {
  581. const _this = this
  582. // 光标移出,值发生改变再调用编辑接口
  583. if (val && val != record.qtyBackups) {
  584. _this.spinning = true
  585. salesDetailUpdateQty({
  586. salesBillDetailSn: record.salesBillDetailSn,
  587. qty: record.qty,
  588. salesBillSn: _this.salesBillSn,
  589. salesPromoSn: _this.promo.salesPromoSn
  590. }).then(res => {
  591. if (res.status == 200) {
  592. _this.resetSearchForm(true)
  593. _this.$emit('insterOk','promo')
  594. _this.$message.success(res.message)
  595. }
  596. _this.spinning = false
  597. })
  598. } else {
  599. record.qty = record.qtyBackups
  600. }
  601. },
  602. // 删除产品
  603. handleDel (row) {
  604. const _this = this
  605. this.$confirm({
  606. title: '提示',
  607. content: '确认要删除吗?',
  608. centered: true,
  609. closable: true,
  610. onOk () {
  611. _this.delLoading = true
  612. _this.spinning = true
  613. salesDetailDel({ salesBillDetailSn: row.salesBillDetailSn, salesBillSn: _this.salesBillSn, salesPromoSn: _this.promo.salesPromoSn }).then(res => {
  614. if (res.status == 200) {
  615. _this.resetSearchForm(true)
  616. _this.$message.success(res.message)
  617. }
  618. _this.delLoading = false
  619. _this.spinning = false
  620. })
  621. }
  622. })
  623. },
  624. // 确定更换促销活动
  625. async upActiveOk(data, editRow){
  626. this.spinning = true
  627. const params = {
  628. salesBillDetailSn: editRow.salesBillDetailSn,
  629. salesBillSn: this.salesBillSn,
  630. oldSalesPromoSn: this.promo.salesPromoSn
  631. }
  632. // 更换活动
  633. this.$emit("upActive",this.promo, data, params)
  634. },
  635. upAcitveSuccess(){
  636. this.spinning = false
  637. this.openUpActiveModal = false
  638. this.resetSearchForm()
  639. },
  640. // 添加产品
  641. insterProduct (row, promotionFlag, promoProductClz) {
  642. console.log(row, promotionFlag, promoProductClz)
  643. // 防止多次添加产品
  644. if (this.isInster) { return }
  645. this.saveNewProduct(row, promotionFlag, promoProductClz)
  646. },
  647. // 保存添加的产品到销售列表
  648. saveNewProduct (row, promotionFlag, promoProductClz) {
  649. this.$message.loading('正在添加产品...', 1)
  650. this.isInster = true
  651. this.spinning = true
  652. console.log(row)
  653. const params = {
  654. salesPromoSn: this.promo.salesPromoSn,
  655. promoRuleSn: this.promo.promoRuleSn,
  656. promoSn: this.promo.promoSn,
  657. promoProductClz: promoProductClz,
  658. packQty: row.productPackQty,
  659. productSn: row.productSn,
  660. showCost: row.lastStockCost,
  661. price: row.productPrice,
  662. origPrice: row.origPrice,
  663. promotionGiftsAmount: 0,
  664. usePromotionGiftsAmount: 0,
  665. qty: row.salesNums,
  666. salesBillSn: this.detailData.salesBillSn,
  667. salesBillNo: this.detailData.salesBillNo,
  668. purchaseBillSn: this.detailData.purchaseBillSn,
  669. purchaseBillNo: this.detailData.purchaseBillNo,
  670. stockSn: row.stockSn,
  671. promotableFlag: row.isJoinActivityProduct || 0, // 可促销标记 有活动的传1,没活动的传0
  672. promotionFlag: promotionFlag, // 促销标记 正品传0,促销品传1
  673. warehouseSn: row.warehouseSn
  674. }
  675. salesDetailInsert(params).then(res => {
  676. if (res.status == 200) {
  677. this.resetSearchForm()
  678. this.$message.success('产品添加成功', 2.5)
  679. this.$emit('insterOk','promo')
  680. }
  681. this.spinning = false
  682. this.isInster = false
  683. }).catch(err => {
  684. this.isInster = false
  685. this.spinning = false
  686. })
  687. },
  688. // 导入产品
  689. handleImportClick(e){
  690. console.log(e)
  691. this.openGuideModal = true
  692. this.promoProductClz = e.key
  693. },
  694. closeGuideModel () {
  695. this.openGuideModal = false
  696. this.promoProductClz = ''
  697. },
  698. // 批量导入产品
  699. hanldeImportOk (data, salesPromoSn) {
  700. const params = {
  701. salesBillSn: this.detailData.salesBillSn,
  702. salesBillDetailList: data
  703. }
  704. // 活动导入
  705. if(salesPromoSn){
  706. params.salesPromoSn = salesPromoSn
  707. params.promoRuleSn = this.promo.promoRuleSn
  708. params.promoProductClz = this.promoProductClz
  709. }
  710. salesBatchInsert(params).then(res => {
  711. if (res.status == 200) {
  712. this.$refs.table.refresh(true)
  713. this.getOrderDetail(false)
  714. }
  715. })
  716. },
  717. }
  718. }
  719. </script>
  720. <style lang="less">
  721. .alert-bar{
  722. display: flex;
  723. justify-content: space-between;
  724. align-items: center;
  725. > div{
  726. &:first-child{
  727. flex-grow: 1;
  728. width:70%;
  729. padding-right: 100px;
  730. }
  731. }
  732. }
  733. </style>