productList.vue 29 KB

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