productList.vue 25 KB

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