productList.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  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. 40
  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="salesNums" slot-scope="text, record">
  164. <a-input-number
  165. id="salesEdit-qty"
  166. size="small"
  167. v-model="record.qty"
  168. :precision="0"
  169. :min="1"
  170. :max="999999"
  171. placeholder="请输入"
  172. @blur="e => onCellBlur(e.target.value, record)"
  173. style="width: 100%;" />
  174. </template>
  175. <!-- 当前库存 -->
  176. <template slot="stockQty" slot-scope="text, record">
  177. <div v-if="record.stockQty || record.stockQty==0">
  178. <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>
  179. <p style="margin: 0;" v-else>{{ record.stockQty }}</p>
  180. </div>
  181. <span v-else>--</span>
  182. </template>
  183. <!-- 出库仓库 -->
  184. <template slot="warehouseBox" slot-scope="text, record">
  185. <a-select
  186. size="small"
  187. style="width:100%;"
  188. placeholder="请选择仓库"
  189. v-model="record.warehouseSn"
  190. :showSearch="true"
  191. @change="handleWarehouseBox(record)"
  192. mode="default"
  193. :filter-option="filterOption">
  194. <a-select-option v-for="item in warehouseDataList" :key="item.warehouseSn" :value="item.warehouseSn">{{ item.name }}</a-select-option>
  195. </a-select>
  196. </template>
  197. <!-- 操作 -->
  198. <template slot="action" slot-scope="text, record">
  199. <a-button
  200. size="small"
  201. type="link"
  202. :loading="delLoading"
  203. class="button-error"
  204. @click="handleDel(record)"
  205. >删除</a-button>
  206. <a-button
  207. size="small"
  208. type="link"
  209. :loading="delLoading"
  210. class="button-primary"
  211. @click="handleUpdateActive(record)"
  212. >换促销</a-button>
  213. </template>
  214. <template slot="footer" slot-scope="currentPageData">
  215. <!-- 总计 -->
  216. <a-alert type="info" banner :showIcon="false">
  217. <div slot="message" class="alert-bar">
  218. <div>
  219. {{ countData&&countData.remarks }}
  220. </div>
  221. <div style="display: flex;">
  222. <div>
  223. 款数:<strong>{{ countData&&(countData.totalCategory || countData.totalCategory==0) ? countData.totalCategory : '--' }}</strong>
  224. </div>
  225. <div style="padding: 0 10px;">
  226. 数量:<strong>{{ countData&&(countData.totalQty || countData.totalQty==0) ? countData.totalQty : '--' }}</strong>
  227. </div>
  228. <div>
  229. <div v-if="$hasPermissions('B_salesEdit_salesPrice')">总金额:<strong>{{ countData&&(countData.totalAmount || countData.totalAmount==0) ? toThousands(countData.totalAmount) : '--' }}</strong></div>
  230. <div v-if="$hasPermissions('B_salesEdit_salesPrice')">优惠金额:<strong>-{{ countData&&(countData.lossAmount || countData.lossAmount==0) ? toThousands(countData.lossAmount) : '--' }}</strong></div>
  231. </div>
  232. </div>
  233. </div>
  234. </a-alert>
  235. </template>
  236. </s-table>
  237. <!-- 导入产品 -->
  238. <importGuideModal
  239. :openModal="openGuideModal"
  240. :params="{salesBillSn: $route.params.sn, salesPromoSn: promo.salesPromoSn}"
  241. :promoProductClz="promoProductClz"
  242. @close="closeGuideModel"
  243. @ok="hanldeImportOk" />
  244. <!-- 仓库设置 -->
  245. <setWarehouse :show="openWarehouseModal" @ok="chooseWarehouseOk" @cancel="openWarehouseModal=false"></setWarehouse>
  246. <!-- 换促销 -->
  247. <updateActiveModal ref="updateActive" :show="openUpActiveModal" @ok="upActiveOk" @cancel="openUpActiveModal=false"></updateActiveModal>
  248. </div>
  249. </template>
  250. <script>
  251. import { commonMixin } from '@/utils/mixin'
  252. import { STable, VSelect } from '@/components'
  253. import ImportGuideModal from './importGuideModal.vue'
  254. import setWarehouse from './setWarehouse.vue'
  255. import updateActiveModal from './updateActiveModal.vue'
  256. import chooseWarehouse from '@/views/common/chooseWarehouse'
  257. import ProductBrand from '@/views/common/productBrand.js'
  258. import productTypeAll from '@/views/common/productTypeAll.js'
  259. import { salesDetailList, salesPromoDetailCount, salesDetailInsert, salesDetailUpdateQty, salesDetailDel, salesDetailBatchDel, deleteAll, updateWarehouse, salesBatchInsert } from '@/api/salesDetailNew'
  260. export default {
  261. name: 'ProductList',
  262. mixins: [commonMixin],
  263. components: {
  264. STable,
  265. VSelect,
  266. ImportGuideModal,
  267. chooseWarehouse,
  268. setWarehouse,
  269. ProductBrand,
  270. productTypeAll,
  271. updateActiveModal
  272. },
  273. props: {
  274. openModal: { // 弹框显示状态
  275. type: Boolean,
  276. default: false
  277. },
  278. newLoading: Boolean,
  279. detailData: {
  280. type: Object,
  281. default: function(){return null}
  282. },
  283. promo: {
  284. type: Object,
  285. default: function(){return null}
  286. },
  287. id: {
  288. type: String,
  289. default: ''
  290. },
  291. warehouseSn: {
  292. type: String,
  293. default: ''
  294. },
  295. salesBillSn: {
  296. type: String,
  297. default: ''
  298. }
  299. },
  300. data () {
  301. return {
  302. spinning: false,
  303. // 加载数据方法 必须为 Promise 对象
  304. loadData: parameter => {
  305. this.disabled = true
  306. this.queryParam.salesBillSn = this.salesBillSn || ''
  307. this.getCount()
  308. return salesDetailList(Object.assign(parameter, this.queryParam, {
  309. showStock: true,
  310. promoRuleSn: this.promo.promoRuleSn,
  311. promoSn: this.promo.promoSn,
  312. salesPromoSn: this.promo.salesPromoSn
  313. })).then(res => {
  314. let data
  315. if (res.status == 200) {
  316. data = res.data
  317. const no = (data.pageNo - 1) * data.pageSize
  318. for (var i = 0; i < data.list.length; i++) {
  319. data.list[i].no = no + i + 1
  320. data.list[i].qtyBackups = data.list[i].qty
  321. }
  322. this.disabled = false
  323. this.dataSource = data.list
  324. }
  325. return data
  326. })
  327. },
  328. showSearchBox: false,
  329. showDescBox: false,
  330. openWarehouseModal: false, // 打开仓库设置
  331. openGuideModal: false, // 导入产品引导
  332. delLoading: false,
  333. chooseDisabled: false,
  334. disabled: false, // 查询、重置按钮是否可操作
  335. queryParam: {
  336. warehouseSn: undefined,
  337. productCode: '',
  338. productName: '',
  339. productBrandSn: undefined,
  340. productTypeSn1: '', // 产品一级分类
  341. productTypeSn2: '', // 产品二级分类
  342. productTypeSn3: '' // 产品三级分类
  343. },
  344. productType: [],
  345. rowSelectionInfo: null,
  346. warehouseDataList: [],
  347. openUpActiveModal: false,
  348. descDetail: null,
  349. promoProductClz: null, // 活动产品分类
  350. disablePromo: false,
  351. countData: null
  352. }
  353. },
  354. computed: {
  355. selectTotal () {
  356. return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length || 0
  357. },
  358. columns () {
  359. const arr = [
  360. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  361. { title: '产品编码', dataIndex: 'productEntity.code', scopedSlots: { customRender: 'productCode' }, width: '13%', align: 'center', sorter: true },
  362. { title: '产品名称', dataIndex: 'productEntity.name', scopedSlots: { customRender: 'productName' }, width: '20%', align: 'left' },
  363. // { title: '售价', dataIndex: 'price', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  364. { title: '销售数量', scopedSlots: { customRender: 'salesNums' }, width: '8%', align: 'center' },
  365. { title: '库存', dataIndex: 'stockQty', scopedSlots: { customRender: 'stockQty' }, width: '8%', align: 'center' },
  366. { title: '出库仓库', scopedSlots: { customRender: 'warehouseBox' }, width: '15%', align: 'center' },
  367. { title: '单位', dataIndex: 'productEntity.unit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  368. // { title: '售价小计', dataIndex: 'totalAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  369. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  370. ]
  371. if (this.$hasPermissions('B_salesEdit_salesPrice')) { // 售价权限
  372. arr.splice(3, 0, { title: '售价', dataIndex: 'price', width: '8%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  373. arr.splice(7, 0, { title: '售价小计', dataIndex: 'totalAmount', width: '8%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  374. }
  375. return arr
  376. }
  377. },
  378. watch: {
  379. salesBillSn(newValue, oldValue) {
  380. this.resetSearchForm()
  381. }
  382. },
  383. methods: {
  384. filterOption (input, option) {
  385. return (
  386. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  387. )
  388. },
  389. warehouseLoad(sn,list){
  390. this.warehouseDataList = list
  391. },
  392. showSearch(){
  393. this.showSearchBox = !this.showSearchBox
  394. },
  395. showDesc(descDetail){
  396. this.showDescBox = !this.showDescBox
  397. this.descDetail = descDetail
  398. },
  399. openCpModal(){
  400. this.$emit('openCpModal', 1, this.id)
  401. },
  402. // 表格选中项
  403. rowSelectionFun (obj) {
  404. this.rowSelectionInfo = obj || null
  405. },
  406. // 产品分类 change
  407. changeProductType (val, opt) {
  408. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  409. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  410. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  411. },
  412. // 禁用活动
  413. disableActive(){
  414. this.resetSearchForm()
  415. this.disablePromo = true
  416. },
  417. // 统计
  418. getCount(){
  419. salesPromoDetailCount(Object.assign(this.queryParam, {
  420. salesBillSn: this.salesBillSn,
  421. promoRuleSn: this.promo.promoRuleSn,
  422. promoSn: this.promo.promoSn,
  423. salesPromoSn: this.promo.salesPromoSn
  424. })).then(res => {
  425. if(res.status == 200){
  426. this.countData = res.data
  427. }
  428. })
  429. },
  430. // 重置
  431. resetSearchForm (flag) {
  432. this.queryParam.productCode = ''
  433. this.queryParam.productName = ''
  434. this.queryParam.warehouseSn = undefined
  435. this.queryParam.productBrandSn = undefined
  436. this.queryParam.productTypeSn1 = ''
  437. this.queryParam.productTypeSn2 = ''
  438. this.queryParam.productTypeSn3 = ''
  439. this.productType = []
  440. this.$refs.table.clearSelected()
  441. this.$refs.table.refresh(!!flag)
  442. },
  443. // 删除全部产品
  444. handleBatchDelAll () {
  445. const _this = this
  446. if (_this.dataSource.length == 0) {
  447. _this.$message.warning('暂无可删除的已选产品!')
  448. return
  449. }
  450. this.$confirm({
  451. title: '提示',
  452. content: '确认要删除全部已选产品吗?',
  453. centered: true,
  454. onOk () {
  455. _this.spinning = true
  456. deleteAll({ salesBillSn: _this.salesBillSn, salesPromoSn: _this.promo.salesPromoSn }).then(res => {
  457. if (res.status == 200) {
  458. _this.resetSearchForm(true)
  459. _this.$message.success(res.message)
  460. }
  461. _this.spinning = false
  462. })
  463. }
  464. })
  465. },
  466. // 批量删除已选产品
  467. handleBatchDel () {
  468. const _this = this
  469. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  470. _this.$message.warning('请先选择要删除的产品后再进行批量操作!')
  471. return
  472. }
  473. const obj = []
  474. _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
  475. obj.push(item.salesBillDetailSn)
  476. })
  477. this.$confirm({
  478. title: '提示',
  479. content: '已选产品' + obj.length + '项,确认要批量删除吗?',
  480. centered: true,
  481. onOk () {
  482. _this.spinning = true
  483. salesDetailBatchDel({
  484. salesBillSn: _this.salesBillSn,
  485. salesPromoSn: _this.promo.salesPromoSn,
  486. salesBillDetailSnList: obj
  487. }).then(res => {
  488. if (res.status == 200) {
  489. _this.resetSearchForm(true)
  490. _this.$message.success(res.message)
  491. }
  492. _this.spinning = false
  493. })
  494. }
  495. })
  496. },
  497. // 设置单个出库仓库
  498. handleWarehouseBox (row) {
  499. const snArr = [row.salesBillDetailSn]
  500. const ajax_data = {
  501. warehouseSn: row.warehouseSn,
  502. salesBillDetailSnList: snArr,
  503. salesBillSn: this.salesBillSn,
  504. salesPromoSn: this.promo.salesPromoSn
  505. }
  506. this.setWarehouseInfo(ajax_data)
  507. },
  508. chooseWarehouseOk (sn) {
  509. const _this = this
  510. const snArr = []
  511. _this.rowSelectionInfo.selectedRows.forEach(item => {
  512. snArr.push(item.salesBillDetailSn)
  513. })
  514. const ajax_data = {
  515. warehouseSn: sn,
  516. salesBillDetailSnList: snArr,
  517. salesBillSn: _this.salesBillSn,
  518. salesPromoSn: _this.promo.salesPromoSn
  519. }
  520. _this.setWarehouseInfo(ajax_data)
  521. },
  522. setWarehouseInfo (data) {
  523. const _this = this
  524. _this.spinning = true
  525. updateWarehouse(data).then(res => {
  526. if (res.status == 200) {
  527. _this.openWarehouseModal = false
  528. _this.resetSearchForm(true)
  529. _this.$message.success(res.message)
  530. }
  531. _this.$refs.table.refresh(true)
  532. _this.spinning = false
  533. })
  534. },
  535. handleMenuClick (e) {
  536. const _this = this
  537. if (e.key == 0) { // 仓库设置
  538. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  539. _this.$message.warning('请先选择要设置的产品!')
  540. } else {
  541. _this.openWarehouseModal = true
  542. }
  543. } else if (e.key == 1) { // 删除已选项
  544. this.handleBatchDel()
  545. } else {
  546. this.handleBatchDelAll()
  547. }
  548. },
  549. // 换促销
  550. async upActiveOk(data, editRow){
  551. console.log(data)
  552. console.log(editRow)
  553. this.spinning = true
  554. // 先删除当前活动
  555. const delRet = await salesDetailDel({
  556. salesBillDetailSn: editRow.salesBillDetailSn,
  557. salesBillSn: this.salesBillSn,
  558. salesPromoSn: this.promo.salesPromoSn
  559. })
  560. // 当删除成功且不是”不参与活动“时
  561. if(delRet.status == 200 && data != 0){
  562. // 再添加到其它活动
  563. }
  564. this.openUpActiveModal = false
  565. this.spinning = false
  566. },
  567. handleUpdateActive(record){
  568. this.$refs.updateActive.getActiveList({
  569. productSn: record.productSn,
  570. salesBillSn: this.salesBillSn,
  571. promoRuleSn: this.promo.promoRuleSn
  572. },record)
  573. this.openUpActiveModal = true
  574. },
  575. // 已选产品 blur
  576. onCellBlur (val, record) {
  577. const _this = this
  578. // 光标移出,值发生改变再调用编辑接口
  579. if (val && val != record.qtyBackups) {
  580. _this.spinning = true
  581. salesDetailUpdateQty({
  582. salesBillDetailSn: record.salesBillDetailSn,
  583. qty: record.qty,
  584. salesBillSn: _this.salesBillSn,
  585. salesPromoSn: _this.promo.salesPromoSn
  586. }).then(res => {
  587. _this.resetSearchForm(true)
  588. if (res.status == 200) {
  589. _this.$message.success(res.message)
  590. }
  591. _this.spinning = false
  592. })
  593. } else {
  594. record.qty = record.qtyBackups
  595. }
  596. },
  597. // 删除产品
  598. handleDel (row) {
  599. const _this = this
  600. this.$confirm({
  601. title: '提示',
  602. content: '确认要删除吗?',
  603. centered: true,
  604. closable: true,
  605. onOk () {
  606. _this.delLoading = true
  607. _this.spinning = true
  608. salesDetailDel({ salesBillDetailSn: row.salesBillDetailSn, salesBillSn: _this.salesBillSn, salesPromoSn: _this.promo.salesPromoSn }).then(res => {
  609. if (res.status == 200) {
  610. _this.resetSearchForm(true)
  611. _this.$message.success(res.message)
  612. }
  613. _this.delLoading = false
  614. _this.spinning = false
  615. })
  616. }
  617. })
  618. },
  619. // 添加产品
  620. insterProduct (row, promotionFlag, promoProductClz) {
  621. console.log(row, promotionFlag, promoProductClz)
  622. // 防止多次添加产品
  623. if (this.isInster) { return }
  624. const _this = this
  625. _this.saveNewProduct(row, promotionFlag, promoProductClz)
  626. },
  627. // 保存添加的产品到销售列表
  628. saveNewProduct (row, promotionFlag, promoProductClz) {
  629. this.$message.loading('正在添加产品...', 1)
  630. this.isInster = true
  631. this.spinning = true
  632. salesDetailInsert({
  633. salesPromoSn: this.promo.salesPromoSn,
  634. promoRuleSn: this.promo.promoRuleSn,
  635. promoSn: this.promo.promoSn,
  636. promoProductClz: promoProductClz,
  637. packQty: row.productPackQty,
  638. productSn: row.productSn,
  639. showCost: row.lastStockCost,
  640. price: row.productPrice,
  641. origPrice: row.productPrice,
  642. promotionGiftsAmount: 0,
  643. usePromotionGiftsAmount: 0,
  644. qty: row.salesNums,
  645. salesBillSn: this.detailData.salesBillSn,
  646. salesBillNo: this.detailData.salesBillNo,
  647. purchaseBillSn: this.detailData.purchaseBillSn,
  648. purchaseBillNo: this.detailData.purchaseBillNo,
  649. stockSn: row.stockSn,
  650. promotableFlag: row.isJoinActivityProduct || 0, // 可促销标记 有活动的传1,没活动的传0
  651. promotionFlag: promotionFlag, // 促销标记 正品传0,促销品传1
  652. warehouseSn: row.warehouseSn
  653. }).then(res => {
  654. if (res.status == 200) {
  655. this.resetSearchForm()
  656. this.$message.success('产品添加成功', 2.5)
  657. this.$emit('insterOk')
  658. }
  659. this.spinning = false
  660. this.isInster = false
  661. }).catch(err => {
  662. this.isInster = false
  663. this.spinning = false
  664. })
  665. },
  666. // 导入产品
  667. handleImportClick(e){
  668. console.log(e)
  669. this.openGuideModal = true
  670. this.promoProductClz = e.key
  671. },
  672. closeGuideModel () {
  673. this.openGuideModal = false
  674. this.promoProductClz = ''
  675. },
  676. // 批量导入产品
  677. hanldeImportOk (data, salesPromoSn) {
  678. const params = {
  679. salesBillSn: this.detailData.salesBillSn,
  680. salesBillDetailList: data
  681. }
  682. // 活动导入
  683. if(salesPromoSn){
  684. params.salesPromoSn = salesPromoSn
  685. params.promoRuleSn = this.promo.promoRuleSn
  686. params.promoProductClz = this.promoProductClz
  687. }
  688. salesBatchInsert(params).then(res => {
  689. if (res.status == 200) {
  690. this.$refs.table.refresh(true)
  691. this.getOrderDetail(false)
  692. }
  693. })
  694. },
  695. }
  696. }
  697. </script>
  698. <style lang="less">
  699. .alert-bar{
  700. display: flex;
  701. justify-content: space-between;
  702. align-items: center;
  703. > div{
  704. &:first-child{
  705. flex-grow: 1;
  706. width:70%;
  707. padding-right: 100px;
  708. }
  709. }
  710. }
  711. </style>