productList.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  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. salesDetailBatchDel({
  552. salesBillSn: _this.salesBillSn,
  553. salesPromoSn: _this.promo.salesPromoSn,
  554. salesBillDetailSnList: obj
  555. }).then(res => {
  556. if (res.status == 200) {
  557. _this.$refs.table.refresh(false)
  558. _this.$emit('insterOk', 'promo')
  559. _this.$message.success(res.message)
  560. }
  561. _this.spinning = false
  562. })
  563. }
  564. })
  565. },
  566. // 删除全部产品
  567. handleBatchDelAll () {
  568. const _this = this
  569. if (_this.dataSource.length == 0) {
  570. _this.$message.warning('暂无可删除的已选产品!')
  571. return
  572. }
  573. this.$confirm({
  574. title: '提示',
  575. content: '确认要删除全部已选产品吗?',
  576. centered: true,
  577. onOk () {
  578. _this.spinning = true
  579. deleteAll({ salesBillSn: _this.salesBillSn, salesPromoSn: _this.promo.salesPromoSn }).then(res => {
  580. if (res.status == 200) {
  581. _this.$refs.table.refresh(true)
  582. _this.$emit('insterOk', 'promo')
  583. _this.$message.success(res.message)
  584. }
  585. _this.spinning = false
  586. })
  587. }
  588. })
  589. },
  590. // 批量删除已选产品
  591. handleBatchDel () {
  592. const _this = this
  593. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  594. _this.$message.warning('请先选择要删除的产品后再进行批量操作!')
  595. return
  596. }
  597. const obj = []
  598. _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
  599. obj.push(item.salesBillDetailSn)
  600. })
  601. this.$confirm({
  602. title: '提示',
  603. content: '已选产品' + obj.length + '项,确认要批量删除吗?',
  604. centered: true,
  605. onOk () {
  606. _this.spinning = true
  607. salesDetailBatchDel({
  608. salesBillSn: _this.salesBillSn,
  609. salesPromoSn: _this.promo.salesPromoSn,
  610. salesBillDetailSnList: obj
  611. }).then(res => {
  612. if (res.status == 200) {
  613. _this.$refs.table.refresh(false)
  614. _this.$emit('insterOk', 'promo')
  615. _this.$message.success(res.message)
  616. }
  617. _this.spinning = false
  618. })
  619. }
  620. })
  621. },
  622. // 设置单个出库仓库
  623. handleWarehouseBox (row) {
  624. const snArr = [row.salesBillDetailSn]
  625. const ajax_data = {
  626. warehouseSn: row.warehouseSn,
  627. salesBillDetailSnList: snArr,
  628. salesBillSn: this.salesBillSn,
  629. salesPromoSn: this.promo.salesPromoSn
  630. }
  631. this.setWarehouseInfo(ajax_data)
  632. },
  633. // 选择仓库确认
  634. chooseWarehouseOk (sn) {
  635. const _this = this
  636. const snArr = []
  637. _this.rowSelectionInfo.selectedRows.forEach(item => {
  638. snArr.push(item.salesBillDetailSn)
  639. })
  640. const ajax_data = {
  641. warehouseSn: sn,
  642. salesBillDetailSnList: snArr,
  643. salesBillSn: _this.salesBillSn,
  644. salesPromoSn: _this.promo.salesPromoSn,
  645. allFlag: _this.warehouseTit ? true : undefined
  646. }
  647. _this.setWarehouseInfo(ajax_data)
  648. },
  649. // 更改仓库信息
  650. setWarehouseInfo (data) {
  651. const _this = this
  652. _this.spinning = true
  653. updateWarehouse(data).then(res => {
  654. console.log(res)
  655. if (res.status == 200) {
  656. _this.$message.success(res.message)
  657. _this.$emit('insterOk', 'promo')
  658. }
  659. _this.openWarehouseModal = false
  660. _this.$refs.table.refresh(false)
  661. _this.spinning = false
  662. })
  663. },
  664. // 更多操作下拉菜单
  665. handleMenuClick (e) {
  666. const _this = this
  667. if (e.key == 0) { // 部分仓库设置
  668. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  669. _this.$message.warning('请先选择要设置的产品!')
  670. } else {
  671. _this.openWarehouseModal = true
  672. }
  673. } else if (e.key == 1) { // 删除已选项
  674. this.handleBatchDel()
  675. } else if (e.key == 3) { // 全部仓库设置
  676. _this.$refs.table.clearSelected()
  677. _this.warehouseTit = '全部仓库设置'
  678. _this.openWarehouseModal = true
  679. } else if (e.key == 4) { // 批量取消促销
  680. _this.handleBatchCancelActive()
  681. } else { // 全部删除
  682. _this.handleBatchDelAll()
  683. }
  684. },
  685. // 打开换促销活动列表选项
  686. handleUpdateActive (record) {
  687. this.$refs.updateActive.getActiveList({
  688. productSn: record.productSn,
  689. salesBillSn: this.salesBillSn,
  690. promoRuleSn: this.promo.promoRuleSn
  691. }, record)
  692. this.openUpActiveModal = true
  693. },
  694. // 已选产品数量修改
  695. onCellBlur (val, record) {
  696. const _this = this
  697. // 光标移出,值发生改变再调用编辑接口
  698. if (val && val != record.qtyBackups) {
  699. _this.spinning = true
  700. salesDetailUpdateQty({
  701. salesBillDetailSn: record.salesBillDetailSn,
  702. qty: record.qty,
  703. salesBillSn: _this.salesBillSn,
  704. salesPromoSn: _this.promo.salesPromoSn
  705. }).then(res => {
  706. if (res.status == 200) {
  707. _this.$emit('insterOk', 'promo')
  708. _this.$message.success(res.message)
  709. }
  710. _this.$refs.table.refresh(false)
  711. _this.spinning = false
  712. })
  713. } else {
  714. record.qty = record.qtyBackups
  715. }
  716. },
  717. // 删除产品
  718. handleDel (row) {
  719. const _this = this
  720. this.$confirm({
  721. title: '提示',
  722. content: '确认要删除吗?',
  723. centered: true,
  724. closable: true,
  725. onOk () {
  726. _this.delLoading = true
  727. _this.spinning = true
  728. salesDetailDel({ salesBillDetailSn: row.salesBillDetailSn, salesBillSn: _this.salesBillSn, salesPromoSn: _this.promo.salesPromoSn }).then(res => {
  729. if (res.status == 200) {
  730. _this.$refs.table.refresh(false)
  731. _this.$emit('insterOk', 'promo')
  732. _this.$message.success(res.message)
  733. }
  734. _this.delLoading = false
  735. _this.spinning = false
  736. })
  737. }
  738. })
  739. },
  740. // 确定更换促销活动
  741. async upActiveOk (data, editRow) {
  742. this.spinning = true
  743. const params = {
  744. salesBillDetailSn: editRow.salesBillDetailSn,
  745. salesBillSn: this.salesBillSn,
  746. oldSalesPromoSn: this.promo.salesPromoSn,
  747. priceLevel: editRow.priceLevel
  748. }
  749. // 更换活动
  750. this.$emit('upActive', this.promo, data, params)
  751. },
  752. // 更换活动成功
  753. upAcitveSuccess () {
  754. this.spinning = false
  755. this.$refs.updateActive.confirmLoading = false
  756. this.openUpActiveModal = false
  757. this.$refs.table.refresh(false)
  758. },
  759. // 添加产品
  760. insterProduct (row, promotionFlag, promoProductClz) {
  761. // 防止多次添加产品
  762. if (this.isInster) { return }
  763. this.saveNewProduct(row, promotionFlag, promoProductClz)
  764. },
  765. // 保存添加的产品到销售列表
  766. saveNewProduct (row, promotionFlag, promoProductClz) {
  767. this.$message.loading('正在添加产品...', 1)
  768. this.isInster = true
  769. this.spinning = true
  770. const params = {
  771. salesPromoSn: this.promo.salesPromoSn,
  772. promoRuleSn: this.promo.promoRuleSn,
  773. promoSn: this.promo.promoSn,
  774. promoProductClz: promoProductClz,
  775. packQty: row.productPackQty,
  776. productSn: row.productSn,
  777. showCost: row.lastStockCost,
  778. price: row.productPrice,
  779. origPrice: row.origPrice,
  780. promotionGiftsAmount: 0,
  781. usePromotionGiftsAmount: 0,
  782. qty: row.salesNums,
  783. salesBillSn: this.detailData.salesBillSn,
  784. salesBillNo: this.detailData.salesBillNo,
  785. purchaseBillSn: this.detailData.purchaseBillSn,
  786. purchaseBillNo: this.detailData.purchaseBillNo,
  787. priceLevel: row.priceLevel,
  788. stockSn: row.stockSn,
  789. promotableFlag: row.isJoinActivityProduct || 0, // 可促销标记 有活动的传1,没活动的传0
  790. promotionFlag: promotionFlag, // 促销标记 正品传0,促销品传1
  791. warehouseSn: row.warehouseSn
  792. }
  793. salesDetailInsert(params).then(res => {
  794. if (res.status == 200) {
  795. this.$message.success('产品添加成功', 2.5)
  796. this.resetSearchForm(true)
  797. this.$emit('insterOk', 'promo')
  798. }
  799. this.spinning = false
  800. this.isInster = false
  801. }).catch(err => {
  802. this.isInster = false
  803. this.spinning = false
  804. })
  805. },
  806. // 导入产品
  807. handleImportClick (e) {
  808. console.log(e)
  809. this.openGuideModal = true
  810. this.promoProductClz = e.key
  811. },
  812. // 关闭导入弹框
  813. closeGuideModel () {
  814. this.openGuideModal = false
  815. this.promoProductClz = ''
  816. },
  817. // 批量导入产品
  818. hanldeImportOk (data, salesPromoSn) {
  819. const params = {
  820. salesBillSn: this.detailData.salesBillSn,
  821. salesBillDetailList: data
  822. }
  823. // 活动导入
  824. if (salesPromoSn) {
  825. params.salesPromoSn = salesPromoSn
  826. params.promoRuleSn = this.promo.promoRuleSn
  827. params.promoProductClz = this.promoProductClz
  828. }
  829. salesBatchInsert(params).then(res => {
  830. if (res.status == 200) {
  831. this.$message.success('产品导入成功', 2.5)
  832. this.resetSearchForm(true)
  833. this.$emit('insterOk', 'promo')
  834. }
  835. })
  836. }
  837. }
  838. }
  839. </script>
  840. <style lang="less">
  841. .ant-input-number-sm input{
  842. text-align: center;
  843. }
  844. .alert-bar{
  845. display: flex;
  846. justify-content: space-between;
  847. align-items: center;
  848. .countData{
  849. span{
  850. margin: 0 2px;
  851. color: rgb(0, 153, 255);
  852. }
  853. span.cor1{
  854. color: rgb(248, 132, 0);
  855. }
  856. b{
  857. font-weight: bold;
  858. span{
  859. color: red;
  860. font-weight: normal;
  861. }
  862. }
  863. }
  864. > div{
  865. &:first-child{
  866. flex-grow: 1;
  867. width:70%;
  868. padding-right: 100px;
  869. }
  870. }
  871. }
  872. </style>