productList.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  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="99999999"
  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. arr.splice(4, 0, { title: '价格级别', dataIndex: 'priceLevelDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } })
  413. let idx = 0
  414. // 如果是特价活动
  415. if (this.promo.promotionRule.promotionRuleType == 'PROMO_PROD') {
  416. idx = idx + 1
  417. arr.splice(5, 0, { title: '折扣', dataIndex: 'discountPrice', width: '6%', align: 'right', scopedSlots: { customRender: 'discountPrice' } })
  418. }
  419. arr.splice(8 + idx, 0, { title: '售价小计', dataIndex: 'totalAmount', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  420. }
  421. return arr
  422. }
  423. },
  424. watch: {
  425. salesBillSn (newValue, oldValue) {
  426. this.resetSearchForm()
  427. }
  428. },
  429. methods: {
  430. filterOption (input, option) {
  431. return (
  432. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  433. )
  434. },
  435. warehouseLoad (sn, list) {
  436. this.warehouseDataList = list
  437. },
  438. showSearch () {
  439. this.showSearchBox = !this.showSearchBox
  440. },
  441. showDesc (descDetail) {
  442. this.showDescBox = !this.showDescBox
  443. this.descDetail = descDetail
  444. this.descDetail.gateValue = Number(this.descDetail.gateValue).toFixed(2)
  445. this.descDetail.quotaAmount = Number(this.descDetail.quotaAmount).toFixed(2)
  446. this.$emit('showDesc', this.showDescBox)
  447. },
  448. openCpModal () {
  449. this.$emit('openCpModal', 1, this.id, this.countData)
  450. },
  451. // 表格选中项
  452. rowSelectionFun (obj) {
  453. this.rowSelectionInfo = obj || null
  454. },
  455. // 产品分类 change
  456. changeProductType (val, opt) {
  457. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  458. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  459. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  460. },
  461. // 禁用活动
  462. disableActive (flag) {
  463. console.log(flag, '------')
  464. this.disablePromo = flag
  465. },
  466. // 统计
  467. getCount () {
  468. salesPromoDetailCount(Object.assign(this.queryParam, {
  469. salesBillSn: this.salesBillSn,
  470. promoRuleSn: this.promo.promoRuleSn,
  471. promoSn: this.promo.promoSn,
  472. salesPromoSn: this.promo.salesPromoSn
  473. })).then(res => {
  474. if (res.status == 200) {
  475. this.countData = res.data
  476. }
  477. })
  478. },
  479. // 重置
  480. resetSearchForm (flag) {
  481. this.queryParam.productCode = ''
  482. this.queryParam.productName = ''
  483. this.queryParam.warehouseSn = undefined
  484. this.queryParam.productBrandSn = undefined
  485. this.queryParam.productTypeSn1 = ''
  486. this.queryParam.productTypeSn2 = ''
  487. this.queryParam.productTypeSn3 = ''
  488. this.productType = []
  489. this.rowSelectionInfo = null
  490. this.$refs.table.clearSelected()
  491. this.$refs.table.refresh(!!flag)
  492. },
  493. // 删除全部产品
  494. handleBatchDelAll () {
  495. const _this = this
  496. if (_this.dataSource.length == 0) {
  497. _this.$message.warning('暂无可删除的已选产品!')
  498. return
  499. }
  500. this.$confirm({
  501. title: '提示',
  502. content: '确认要删除全部已选产品吗?',
  503. centered: true,
  504. onOk () {
  505. _this.spinning = true
  506. deleteAll({ salesBillSn: _this.salesBillSn, salesPromoSn: _this.promo.salesPromoSn }).then(res => {
  507. if (res.status == 200) {
  508. _this.$refs.table.refresh(true)
  509. _this.$emit('insterOk', 'promo')
  510. _this.$message.success(res.message)
  511. }
  512. _this.spinning = false
  513. })
  514. }
  515. })
  516. },
  517. // 批量删除已选产品
  518. handleBatchDel () {
  519. const _this = this
  520. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  521. _this.$message.warning('请先选择要删除的产品后再进行批量操作!')
  522. return
  523. }
  524. const obj = []
  525. _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
  526. obj.push(item.salesBillDetailSn)
  527. })
  528. this.$confirm({
  529. title: '提示',
  530. content: '已选产品' + obj.length + '项,确认要批量删除吗?',
  531. centered: true,
  532. onOk () {
  533. _this.spinning = true
  534. salesDetailBatchDel({
  535. salesBillSn: _this.salesBillSn,
  536. salesPromoSn: _this.promo.salesPromoSn,
  537. salesBillDetailSnList: obj
  538. }).then(res => {
  539. if (res.status == 200) {
  540. _this.$refs.table.refresh(false)
  541. _this.$emit('insterOk', 'promo')
  542. _this.$message.success(res.message)
  543. }
  544. _this.spinning = false
  545. })
  546. }
  547. })
  548. },
  549. // 设置单个出库仓库
  550. handleWarehouseBox (row) {
  551. const snArr = [row.salesBillDetailSn]
  552. const ajax_data = {
  553. warehouseSn: row.warehouseSn,
  554. salesBillDetailSnList: snArr,
  555. salesBillSn: this.salesBillSn,
  556. salesPromoSn: this.promo.salesPromoSn
  557. }
  558. this.setWarehouseInfo(ajax_data)
  559. },
  560. chooseWarehouseOk (sn) {
  561. const _this = this
  562. const snArr = []
  563. _this.rowSelectionInfo.selectedRows.forEach(item => {
  564. snArr.push(item.salesBillDetailSn)
  565. })
  566. const ajax_data = {
  567. warehouseSn: sn,
  568. salesBillDetailSnList: snArr,
  569. salesBillSn: _this.salesBillSn,
  570. salesPromoSn: _this.promo.salesPromoSn,
  571. allFlag: _this.warehouseTit ? true : undefined
  572. }
  573. _this.setWarehouseInfo(ajax_data)
  574. },
  575. setWarehouseInfo (data) {
  576. const _this = this
  577. _this.spinning = true
  578. updateWarehouse(data).then(res => {
  579. console.log(res)
  580. if (res.status == 200) {
  581. _this.$message.success(res.message)
  582. _this.$emit('insterOk', 'promo')
  583. }
  584. _this.openWarehouseModal = false
  585. _this.$refs.table.refresh(false)
  586. _this.spinning = false
  587. })
  588. },
  589. handleMenuClick (e) {
  590. const _this = this
  591. if (e.key == 0) { // 仓库设置
  592. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  593. _this.$message.warning('请先选择要设置的产品!')
  594. } else {
  595. _this.openWarehouseModal = true
  596. }
  597. } else if (e.key == 1) { // 删除已选项
  598. this.handleBatchDel()
  599. } else if (e.key == 3) {
  600. _this.$refs.table.clearSelected()
  601. _this.warehouseTit = '全部仓库设置'
  602. _this.openWarehouseModal = true
  603. } else {
  604. this.handleBatchDelAll()
  605. }
  606. },
  607. // 打开换促销活动列表选项
  608. handleUpdateActive (record) {
  609. this.$refs.updateActive.getActiveList({
  610. productSn: record.productSn,
  611. salesBillSn: this.salesBillSn,
  612. promoRuleSn: this.promo.promoRuleSn
  613. }, record)
  614. this.openUpActiveModal = true
  615. },
  616. // 已选产品 blur
  617. onCellBlur (val, record) {
  618. const _this = this
  619. // 光标移出,值发生改变再调用编辑接口
  620. if (val && val != record.qtyBackups) {
  621. _this.spinning = true
  622. salesDetailUpdateQty({
  623. salesBillDetailSn: record.salesBillDetailSn,
  624. qty: record.qty,
  625. salesBillSn: _this.salesBillSn,
  626. salesPromoSn: _this.promo.salesPromoSn
  627. }).then(res => {
  628. if (res.status == 200) {
  629. _this.$emit('insterOk', 'promo')
  630. _this.$message.success(res.message)
  631. }
  632. _this.$refs.table.refresh(false)
  633. _this.spinning = false
  634. })
  635. } else {
  636. record.qty = record.qtyBackups
  637. }
  638. },
  639. // 删除产品
  640. handleDel (row) {
  641. const _this = this
  642. this.$confirm({
  643. title: '提示',
  644. content: '确认要删除吗?',
  645. centered: true,
  646. closable: true,
  647. onOk () {
  648. _this.delLoading = true
  649. _this.spinning = true
  650. salesDetailDel({ salesBillDetailSn: row.salesBillDetailSn, salesBillSn: _this.salesBillSn, salesPromoSn: _this.promo.salesPromoSn }).then(res => {
  651. if (res.status == 200) {
  652. _this.$refs.table.refresh(false)
  653. _this.$emit('insterOk', 'promo')
  654. _this.$message.success(res.message)
  655. }
  656. _this.delLoading = false
  657. _this.spinning = false
  658. })
  659. }
  660. })
  661. },
  662. // 确定更换促销活动
  663. async upActiveOk (data, editRow) {
  664. this.spinning = true
  665. const params = {
  666. salesBillDetailSn: editRow.salesBillDetailSn,
  667. salesBillSn: this.salesBillSn,
  668. oldSalesPromoSn: this.promo.salesPromoSn
  669. }
  670. // 更换活动
  671. this.$emit('upActive', this.promo, data, params)
  672. },
  673. upAcitveSuccess () {
  674. this.spinning = false
  675. this.openUpActiveModal = false
  676. this.$refs.table.refresh(false)
  677. },
  678. // 添加产品
  679. insterProduct (row, promotionFlag, promoProductClz) {
  680. console.log(row, promotionFlag, promoProductClz)
  681. // 防止多次添加产品
  682. if (this.isInster) { return }
  683. this.saveNewProduct(row, promotionFlag, promoProductClz)
  684. },
  685. // 保存添加的产品到销售列表
  686. saveNewProduct (row, promotionFlag, promoProductClz) {
  687. this.$message.loading('正在添加产品...', 1)
  688. this.isInster = true
  689. this.spinning = true
  690. console.log(row)
  691. const params = {
  692. salesPromoSn: this.promo.salesPromoSn,
  693. promoRuleSn: this.promo.promoRuleSn,
  694. promoSn: this.promo.promoSn,
  695. promoProductClz: promoProductClz,
  696. packQty: row.productPackQty,
  697. productSn: row.productSn,
  698. showCost: row.lastStockCost,
  699. price: row.productPrice,
  700. origPrice: row.origPrice,
  701. promotionGiftsAmount: 0,
  702. usePromotionGiftsAmount: 0,
  703. qty: row.salesNums,
  704. salesBillSn: this.detailData.salesBillSn,
  705. salesBillNo: this.detailData.salesBillNo,
  706. purchaseBillSn: this.detailData.purchaseBillSn,
  707. purchaseBillNo: this.detailData.purchaseBillNo,
  708. priceLevel: row.priceLevel,
  709. stockSn: row.stockSn,
  710. promotableFlag: row.isJoinActivityProduct || 0, // 可促销标记 有活动的传1,没活动的传0
  711. promotionFlag: promotionFlag, // 促销标记 正品传0,促销品传1
  712. warehouseSn: row.warehouseSn
  713. }
  714. salesDetailInsert(params).then(res => {
  715. if (res.status == 200) {
  716. this.$message.success('产品添加成功', 2.5)
  717. this.resetSearchForm(true)
  718. this.$emit('insterOk', 'promo')
  719. }
  720. this.spinning = false
  721. this.isInster = false
  722. }).catch(err => {
  723. this.isInster = false
  724. this.spinning = false
  725. })
  726. },
  727. // 导入产品
  728. handleImportClick (e) {
  729. console.log(e)
  730. this.openGuideModal = true
  731. this.promoProductClz = e.key
  732. },
  733. closeGuideModel () {
  734. this.openGuideModal = false
  735. this.promoProductClz = ''
  736. },
  737. // 批量导入产品
  738. hanldeImportOk (data, salesPromoSn) {
  739. const params = {
  740. salesBillSn: this.detailData.salesBillSn,
  741. salesBillDetailList: data
  742. }
  743. // 活动导入
  744. if (salesPromoSn) {
  745. params.salesPromoSn = salesPromoSn
  746. params.promoRuleSn = this.promo.promoRuleSn
  747. params.promoProductClz = this.promoProductClz
  748. }
  749. salesBatchInsert(params).then(res => {
  750. if (res.status == 200) {
  751. this.$message.success('产品导入成功', 2.5)
  752. this.resetSearchForm(true)
  753. this.$emit('insterOk', 'promo')
  754. }
  755. })
  756. }
  757. }
  758. }
  759. </script>
  760. <style lang="less">
  761. .ant-input-number-sm input{
  762. text-align: center;
  763. }
  764. .alert-bar{
  765. display: flex;
  766. justify-content: space-between;
  767. align-items: center;
  768. .countData{
  769. span{
  770. margin: 0 2px;
  771. color: rgb(0, 153, 255);
  772. }
  773. span.cor1{
  774. color: rgb(248, 132, 0);
  775. }
  776. b{
  777. font-weight: bold;
  778. span{
  779. color: red;
  780. font-weight: normal;
  781. }
  782. }
  783. }
  784. > div{
  785. &:first-child{
  786. flex-grow: 1;
  787. width:70%;
  788. padding-right: 100px;
  789. }
  790. }
  791. }
  792. </style>