productList.vue 30 KB

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