productList.vue 30 KB

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