productList.vue 30 KB

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