productList.vue 25 KB

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