productList.vue 29 KB

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