productList.vue 34 KB

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