productList.vue 31 KB

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