productList.vue 32 KB

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