productList.vue 34 KB

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