productList.vue 29 KB

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