productList.vue 31 KB

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