productList.vue 28 KB

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