queryPart.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829
  1. <template>
  2. <div class="productInfoList-wrap" style="position: relative;">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchTable">
  6. <a-row :gutter="15">
  7. <a-col :md="4" :sm="24">
  8. <a-form-item label="产品名称">
  9. <a-input id="productInfoList-name" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="4" :sm="24">
  13. <a-form-item label="产品编码">
  14. <a-input id="productInfoList-code" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="4" :sm="24" v-if="hasPrompActive">
  18. <a-form-item label="产品类型">
  19. <a-select allowClear v-model.trim="queryParam.promotionFlag" :dropdownMatchSelectWidth="false" placeholder="请选择产品类型">
  20. <a-select-option value="0">
  21. 正常产品
  22. </a-select-option>
  23. <a-select-option value="REGULAR">
  24. 正价产品(活动)
  25. </a-select-option>
  26. <a-select-option value="DISCOUNT">
  27. 特价产品
  28. </a-select-option>
  29. <a-select-option value="GIFT">
  30. 促销产品
  31. </a-select-option>
  32. <a-select-option value="convertPromoGiftsFlag" v-if="showConvertPromoGifts">
  33. 促销产品(转采购额)
  34. </a-select-option>
  35. <a-select-option value="GATE">
  36. 门槛产品
  37. </a-select-option>
  38. </a-select>
  39. </a-form-item>
  40. </a-col>
  41. <a-col :md="4" :sm="24">
  42. <a-form-item label="下推类型">
  43. <a-select allowClear v-model.trim="queryParam.pushProductType" :dropdownMatchSelectWidth="false" placeholder="请选择下推类型">
  44. <a-select-option value="">
  45. 全部产品
  46. </a-select-option>
  47. <a-select-option value="ABLE">
  48. 剩余待下推数量>0的产品
  49. </a-select-option>
  50. <a-select-option value="ALL">
  51. 可全部下推的产品
  52. </a-select-option>
  53. <a-select-option value="NOTALL">
  54. 不可全部下推的产品
  55. </a-select-option>
  56. </a-select>
  57. </a-form-item>
  58. </a-col>
  59. <a-col :md="4" :sm="24">
  60. <a-form-item label="出库仓库">
  61. <chooseWarehouse ref="warehouse" v-model="queryParam.warehouseSn"></chooseWarehouse>
  62. </a-form-item>
  63. </a-col>
  64. <a-col :md="4" :sm="24" style="margin-bottom: 10px;">
  65. <a-button type="primary" @click="searchTable" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  66. <a-button style="margin-left: 5px" @click="resetSearchForm(null)" id="productInfoList-reset">重置</a-button>
  67. </a-col>
  68. </a-row>
  69. </a-form>
  70. </div>
  71. <!-- alert -->
  72. <div style="margin-bottom: 10px;display: flex;align-items: center;" v-if="detailData">
  73. <div style="display: flex;align-items: center;">
  74. <a-button id="dispatch-plAdd" type="primary" :disabled="newLoading" class="button-info" @click="handlePlAdd">批量添加</a-button>
  75. <a-button
  76. id="dispatch-plPurchase"
  77. type="primary"
  78. :disabled="newLoading"
  79. class="button-info"
  80. v-if="showConvertPromoGifts"
  81. @click="handlePlPurchase">批量转采购额</a-button>
  82. <a-button
  83. id="dispatch-plCancel"
  84. type="primary"
  85. v-if="hasNormalProduct"
  86. ghost
  87. style="margin-left:6px;"
  88. :disabled="newLoading"
  89. @click="handlePlCancel">批量取消</a-button>
  90. <a-button
  91. id="dispatch-cancelAll"
  92. type="primary"
  93. v-if="hasPrompActive&&hasNoPushedActive"
  94. ghost
  95. style="margin-left:6px;"
  96. :disabled="newLoading"
  97. @click="handleAllCancel">整单取消</a-button>
  98. <a-tooltip placement="top" v-if="hasPrompActive&&hasNoPushedActive" style="margin-left:6px;">
  99. <template slot="title">
  100. <span>参加促销活动的产品,不能单独取消,只能整单取消。</span>
  101. </template>
  102. <a-icon style="font-size: 14px;" type="question-circle" />
  103. </a-tooltip>
  104. <span style="margin-left: 10px;" v-if="selectedRowKeys.length">已选 {{ selectedRowKeys.length }} 项</span>
  105. <a-button
  106. @click="confirPurchaseModal"
  107. :loading="loading"
  108. type="primary"
  109. style="margin-left: 15px"
  110. class="button-info"
  111. id="dispatch-updateStock">整单转采购单</a-button>
  112. </div>
  113. <div style="padding-left: 20px;">
  114. 总销售数量:<strong>{{ detailData&&(detailData.totalQty || detailData.totalQty==0) ? detailData.totalQty : '--' }}</strong>;
  115. 已取消数量:<strong>{{ detailData&&(detailData.totalCancelQty || detailData.totalCancelQty==0) ? detailData.totalCancelQty : '--' }}</strong>;
  116. 已下推数量:<strong>{{ detailData&&(detailData.totalPushedQty || detailData.totalPushedQty==0) ? detailData.totalPushedQty : '--' }}</strong>;
  117. 待下推数量:<strong>{{ detailData&&(detailData.totalUnpushedQty || detailData.totalUnpushedQty==0) ? detailData.totalUnpushedQty : '--' }}</strong>;
  118. <span v-if="$hasPermissions('B_salesDispatch_salesPrice')">总售价:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? toThousands(detailData.totalAmount) : '--' }}</strong>;</span>
  119. <span v-if="$hasPermissions('B_salesDispatch_costPrice')">总成本:<strong>{{ detailData&&(detailData.totalCost || detailData.totalCost==0) ? toThousands(detailData.totalCost) : '--' }}</strong>;</span>
  120. <span v-if="$hasPermissions('B_salesDispatch_costPrice')&&$hasPermissions('B_salesDispatch_salesPrice')">总毛利:<strong>{{ detailData&&(detailData.grossProfit || detailData.grossProfit==0) ? toThousands(detailData.grossProfit) : '--' }}</strong>;</span>
  121. <span v-if="$hasPermissions('B_salesDispatch_salesPrice')">已取消金额:<strong>{{ detailData&&(detailData.totalCancelAmount || detailData.totalCancelAmount==0) ? toThousands(detailData.totalCancelAmount) : '--' }}</strong>;</span>
  122. <span v-if="$hasPermissions('B_salesDispatch_salesPrice')">已下推金额:<strong>{{ detailData&&(detailData.totalPushedAmount || detailData.totalPushedAmount==0) ? toThousands(detailData.totalPushedAmount) :'--' }}</strong>;</span>
  123. <span v-if="$hasPermissions('B_salesDispatch_salesPrice')">待下推金额:<strong>{{ detailData&&(detailData.totalUnpushedAmount || detailData.totalUnpushedAmount==0) ? toThousands(detailData.totalUnpushedAmount) : '--' }}</strong>;</span>
  124. <span v-if="$hasPermissions('B_salesDispatch_salesPrice')&&detailData&&detailData.totalConvertPromoGiftsAmount" style="color:red;">促销产品转采购额金额:<strong>{{ toThousands(detailData.totalConvertPromoGiftsAmount) }}</strong>;</span>
  125. </div>
  126. </div>
  127. <a-spin :spinning="spinning" tip="Loading...">
  128. <ve-table
  129. border-y
  130. :scroll-width="0"
  131. :max-height="tableHeight"
  132. :show-header="showTableHead"
  133. :row-style-option="{clickHighlight: true}"
  134. :cellSelectionOption="{enable: false}"
  135. :virtual-scroll-option="{enable: true}"
  136. :columns="columns"
  137. :table-data="tableData"
  138. row-key-field-name="id"
  139. :cell-style-option="cellStyleOption"
  140. :cell-span-option="cellSpanOption"
  141. :column-width-resize-option="columnWidthResizeOption"
  142. :checkbox-option="checkboxOption"
  143. />
  144. <div v-show="showEmpty" class="empty-data-0"><a-empty description="暂无数据" :image="simpleImage"/></div>
  145. <!-- 活动规则详情 -->
  146. <detailModal :openModal="openDetailModal" :itemSn="detailSn" @close="closeDetailModal"></detailModal>
  147. <!-- 转采购单 -->
  148. <toPurchaseModal :openModal="openPurchaseModal" @ok="showLockStockQty = true" @close="openPurchaseModal=false" ref="purchaseModal"></toPurchaseModal>
  149. </a-spin>
  150. </div>
  151. </template>
  152. <script>
  153. import { commonMixin } from '@/utils/mixin'
  154. import { STable, VSelect } from '@/components'
  155. import { Empty } from 'ant-design-vue'
  156. import detailModal from '@/views/promotionRulesManagement/dealerPromotions/detailModal.vue'
  157. import toPurchaseModal from './toPurchaseModal'
  158. import chooseWarehouse from '@/views/common/chooseWarehouse'
  159. // 接口
  160. import { queryAwaitDispatch } from '@/api/salesDetailNew'
  161. import { getCreatePurchaseFlag } from '@/api/salesNew'
  162. export default {
  163. name: 'QueryPart',
  164. mixins: [commonMixin],
  165. components: { STable, VSelect, chooseWarehouse, detailModal, toPurchaseModal },
  166. props: {
  167. newLoading: { // loading
  168. type: Boolean,
  169. default: false
  170. },
  171. maxHeight: { // 最大高度
  172. type: [String, Number],
  173. default: '300'
  174. },
  175. showHeader: { // 是否显示表格头部
  176. type: Boolean,
  177. default: true
  178. },
  179. activeList: { // 参与的活动列表
  180. type: Array,
  181. default: () => []
  182. }
  183. },
  184. data () {
  185. return {
  186. loading: false,
  187. advanced: true, // 高级搜索 展开/关闭
  188. openDetailModal: false, // 活动规则详情弹框
  189. openPurchaseModal: false, // 转采购单弹框
  190. simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
  191. detailSn: null, // 活动详情sn
  192. productType: [], // 产品类型
  193. salesBillSn: '', // 销售单sn
  194. detailData: null, // 详情数据
  195. queryParam: {
  196. pushProductType: '', // 类型
  197. productCode: '', // 产品编码
  198. productName: '', // 产品名称
  199. promotionFlag: undefined, // 是否促销品
  200. brandSn: undefined, // 产品品牌
  201. productTypeSn1: '', // 产品一级分类
  202. productTypeSn2: '', // 产品二级分类
  203. productTypeSn3: '', // 产品三级分类
  204. salesBillSn: '', // 销售单sn
  205. warehouseSn: undefined, // 仓库sn
  206. convertPromoGiftsFlag: undefined // 转采购额
  207. },
  208. disabled: false, // 查询、重置按钮是否可操作
  209. spinning: false,
  210. dataSource: [], // 原始数据
  211. tableData: [], // 表格数据
  212. cellStyleOption: {
  213. bodyCellClass: ({ row, column, rowIndex }) => {
  214. if (row.id.indexOf('promo-') >= 0 && column.field === 'no') {
  215. return 'table-body-cell-no'
  216. }
  217. }
  218. },
  219. // 可拖曳调整列宽
  220. columnWidthResizeOption: {
  221. enable: true,
  222. minWidth: 50
  223. },
  224. // 自定义单元格
  225. cellSpanOption: {
  226. bodyCellSpan: this.bodyCellSpan
  227. },
  228. showEmpty: false, // 空图片
  229. showTableHead: true, // 表格头部
  230. disableSelectedRowKeys: [], // 禁用数据
  231. selectedRowKeys: [], // 已选数据
  232. colspanNums: 16, // 列合并数量
  233. hasNormalProduct: false, // 是否有正常产品
  234. showLockStockQty: false // 是否显示锁定库存列
  235. }
  236. },
  237. computed: {
  238. // 表格高度
  239. tableHeight () {
  240. return (this.showEmpty ? 200 : this.maxHeight) + 'px'
  241. },
  242. // 是否有促销活动产品
  243. hasPrompActive () {
  244. return this.detailData && this.detailData.promoFlag == 1
  245. },
  246. // 是否有下推产品
  247. hasNoPushedActive () {
  248. return this.detailData && this.detailData.totalPushedQty == 0 || !this.detailData.totalPushedQty
  249. },
  250. // 是否有转采购额
  251. hasConvertPromoGifts () {
  252. return this.detailData && this.detailData.totalConvertPromoGiftsAmount > 0
  253. },
  254. // 是否显示转采购额选项
  255. showConvertPromoGifts () {
  256. return this.activeList && this.activeList.find(item => item.promotionRule && item.promotionRule.convertExpenseFlag == 1 && item.promotionRule.promotionRuleType == 'BUY_PROD_GIVE_PROD')
  257. },
  258. // 表格复选框
  259. checkboxOption () {
  260. return {
  261. disableSelectedRowKeys: this.disableSelectedRowKeys,
  262. selectedRowKeys: this.selectedRowKeys,
  263. hideSelectAll: this.disableSelectedRowKeys.length == this.tableData.length,
  264. // 行选择改变事件
  265. selectedRowChange: ({ row, isSelected, selectedRowKeys }) => {
  266. this.selectedRowChange({ row, isSelected, selectedRowKeys })
  267. },
  268. // 全选改变事件
  269. selectedAllChange: ({ isSelected, selectedRowKeys }) => {
  270. this.selectedAllChange({ isSelected, selectedRowKeys })
  271. }
  272. }
  273. },
  274. columns () {
  275. const _this = this
  276. // 价格
  277. const priceFormat = function (record, data, h) {
  278. return (
  279. <div>
  280. {_this.toThousands(data)}
  281. {record.promotionFlag == 'GIFT' || record.promotionFlag == 'DISCOUNT' ? (
  282. <span title="原价">({ _this.toThousands(record.origPrice)})</span>
  283. ) : ''}
  284. </div>
  285. )
  286. }
  287. // 数字
  288. const numsFormat = function (data) {
  289. return data || data == 0 ? data : '--'
  290. }
  291. // 单号
  292. const codeFormat = function (record, data, h) {
  293. return (
  294. <div>
  295. <span style="padding-right: 10px;">{data}</span>
  296. {record.promotionFlag.indexOf('GIFT') >= 0 ? <a-badge count="促" numberStyle={{ backgroundColor: '#52c41a', zoom: '0.7' }}/> : ''}
  297. {record.promotionFlag.indexOf('DISCOUNT') >= 0 ? <a-badge count="特" numberStyle={{ backgroundColor: '#faad14', zoom: '0.7' }}/> : ''}
  298. {record.promotionFlag.indexOf('GATE') >= 0 ? <a-badge count="槛" numberStyle={{ backgroundColor: '#108ee9', zoom: '0.7' }}/> : ''}
  299. {record.promotionFlag.indexOf('REGULAR') >= 0 ? <a-badge count="正" numberStyle={{ backgroundColor: '#ff5500', zoom: '0.7' }}/> : ''}
  300. {record.bakConvertPromoGiftsQty ? (<a-badge count="转" numberStyle={{ backgroundColor: '#ffaa00', zoom: '80%' }}></a-badge>) : ''}
  301. {Number((record.tireFlag != 0 ? record.lockStockQty : record.stockQty) || 0) < Number(record.unpushedQty || 0) ? (<a-badge count="缺" numberStyle={{ zoom: '0.7' }}></a-badge>) : ''}
  302. </div>
  303. )
  304. }
  305. // 取消数量输入框
  306. const inputFormat = function (record, data, h) {
  307. if (record.unpushedQty > 0) {
  308. return (
  309. <div>
  310. <a-input-number
  311. id={'dispacth-cancelNums-' + record.productSn}
  312. size="small"
  313. value={record.cancelNums}
  314. onChange={e => _this.cancelNumsChange(e, record)}
  315. precision={0}
  316. min={0}
  317. max={record.unpushedQty}
  318. style="width: 100%;"
  319. placeholder="请输入" />
  320. </div>
  321. )
  322. }
  323. return '--'
  324. }
  325. // 转采购额数量输入框
  326. const inputFormat1 = function (record, data, h) {
  327. if (record.unpushedQty >= 0 && record.convertPromoGiftsFlag) {
  328. // 已选
  329. if (_this.selectedRowKeys.includes(record.id)) {
  330. return (
  331. <div>
  332. <a-input-number
  333. id={'dispacth-maxConvertNums-' + record.productSn}
  334. size="small"
  335. value={record.convertPromoGiftsQty}
  336. onChange={e => _this.convertPromoGiftsChange(e, record)}
  337. precision={0}
  338. min={0}
  339. max={record.maxConvertNums}
  340. style="width: 100%;"
  341. placeholder="请输入" />
  342. </div>
  343. )
  344. } else {
  345. return record.convertPromoGiftsQty || 0
  346. }
  347. }
  348. return '--'
  349. }
  350. // 操作按钮
  351. const actionFormat = function (record, data, h) {
  352. if (record.unpushedQty > 0) {
  353. return (
  354. <div>
  355. <a-button
  356. id={'dispacth-handleAdd-' + record.productSn}
  357. size="small"
  358. type="link"
  359. class="button-info"
  360. onClick={() => _this.handleAdd(record)}
  361. >添加</a-button>
  362. </div>
  363. )
  364. }
  365. return '--'
  366. }
  367. // 编号,并且格式化活动分类行
  368. const noFormat = function (record, data, h) {
  369. return (
  370. <div>
  371. {record.id.indexOf('promo-active') >= 0 ? (
  372. <div class="active-title">参与促销的产品</div>
  373. ) : (<span>{data}</span>)}
  374. </div>
  375. )
  376. }
  377. let arr = [
  378. { title: '', field: '', key: 'acheck', width: 50, type: 'checkbox', align: 'center' },
  379. { title: '序号', field: 'no', key: 'a', width: 50, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return noFormat(row, row[column.field], h) } },
  380. { title: '产品编码', field: 'productCode', key: 'b', width: 150, align: 'left', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return codeFormat(row, row[column.field], h) } },
  381. { title: '产品名称', field: 'productName', key: 'c', width: 220, align: 'left', operationColumn: false, ellipsis: { showTitle: true }, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
  382. {
  383. title: '规则数量',
  384. field: 'rulesNums',
  385. key: '4',
  386. width: 60,
  387. align: 'center',
  388. operationColumn: false,
  389. renderBodyCell: ({ row, column, rowIndex }, h) => {
  390. return (
  391. row.promoRuleSnList
  392. ? <a-popover placement="right">
  393. <template slot="content">
  394. {row.promoRuleSnList.map(item => {
  395. return (
  396. <div
  397. id={'dispacth-ruleDetail-' + row.productSn}
  398. title="点击查看详情"
  399. style="padding:5px 0;cursor: pointer;"
  400. onClick={() => _this.showRuleDetail(item)}
  401. >{ _this.activeRuleFilter(item) }</div>
  402. )
  403. })}
  404. </template>
  405. <a-button type="link" id={'dispacth-ruleSn-' + row.productSn} size="small" class="button-info">{row.useRuleQty}<span style="zoom:0.6;color: #666;">个</span></a-button>
  406. </a-popover> : '--'
  407. )
  408. }
  409. },
  410. { title: '原厂编码', field: 'productOrigCode', key: 'd', width: 150, align: 'left', operationColumn: false, ellipsis: { showTitle: true }, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
  411. { title: '出库仓库', field: 'warehouseName', key: 'e', width: 100, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } }
  412. ]
  413. // 单元格合并数量
  414. this.colspanNums = this.showConvertPromoGifts ? 8 : 7
  415. if (this.$hasPermissions('B_salesDispatch_salesPrice')) { // 售价权限
  416. this.colspanNums = this.colspanNums + 1
  417. arr.push({ title: '销售价', field: 'price', width: 80, key: 'f', align: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return priceFormat(row, row[column.field], h) } })
  418. }
  419. if (this.$hasPermissions('B_salesDispatch_costPrice')) { // 成本价权限
  420. this.colspanNums = this.colspanNums + 1
  421. arr.push({ title: '成本价', field: 'showCost', width: 80, key: 'g', align: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return _this.toThousands(row[column.field]) || '--' } })
  422. }
  423. this.colspanNums = this.colspanNums + 8
  424. arr = arr.concat([
  425. { title: '单位', field: 'productOrigUnit', key: 'i', width: 80, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
  426. { title: '可用库存', field: 'stockQty', width: 80, key: 'j', align: 'center', fixed: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } }
  427. ])
  428. if (this.showLockStockQty) {
  429. this.colspanNums = this.colspanNums + 1
  430. arr.push({ title: '锁定库存', field: 'lockStockQty', width: 80, key: 'jk', align: 'center', fixed: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } })
  431. }
  432. arr = arr.concat([
  433. { title: '销售数量', field: 'qty', width: 80, key: 'k', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } },
  434. { title: '已取消', field: 'cancelQty', width: 80, key: 'o', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } },
  435. { title: '已下推', field: 'pushedQty', width: 80, key: 'p', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } },
  436. { title: '待下推', field: 'unpushedQty', width: 80, key: 'q', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } },
  437. { title: '取消数量', field: 'cancelNums', width: 80, key: 'r', align: 'center', fixed: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return inputFormat(row, row[column.field], h) } }
  438. ])
  439. // 是否显示转采购额
  440. if (this.showConvertPromoGifts) {
  441. arr.push({ title: '转采购额数量',
  442. field: 'convertPromoGiftsQty',
  443. width: 80,
  444. key: 'z',
  445. align: 'center',
  446. fixed: 'right',
  447. operationColumn: false,
  448. renderBodyCell: ({ row, column, rowIndex }, h) => {
  449. return inputFormat1(row, row[column.field], h)
  450. } })
  451. }
  452. arr.push({ title: '操作', field: 'action', width: 80, key: 's', align: 'center', fixed: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return actionFormat(row, row[column.field], h) } })
  453. return arr
  454. }
  455. },
  456. methods: {
  457. // 关闭详情弹窗
  458. closeDetailModal () {
  459. this.detailSn = null
  460. this.openDetailModal = false
  461. },
  462. // 参与规则名称
  463. activeRuleFilter (val) {
  464. const row = this.activeList.length && this.activeList.find(item => item.promoRuleSn == val)
  465. return row ? row.promotionRule.description + '-' + row.promotion.description : ''
  466. },
  467. // 查看参与规则详情
  468. showRuleDetail (promoRuleSn) {
  469. this.detailSn = promoRuleSn
  470. this.openDetailModal = true
  471. },
  472. // 合并活动分类单元格
  473. bodyCellSpan ({ row, column, rowIndex }) {
  474. if (row.id.indexOf('promo-') >= 0) {
  475. if (column.field == 'no') {
  476. return {
  477. rowspan: 1,
  478. colspan: this.colspanNums
  479. }
  480. } else {
  481. return {
  482. rowspan: 0,
  483. colspan: 0
  484. }
  485. }
  486. }
  487. },
  488. // 取消数量变更
  489. cancelNumsChange (v, record) {
  490. record.cancelNums = v
  491. this.dataSource.splice()
  492. },
  493. // 转采购数量变更
  494. convertPromoGiftsChange (v, record) {
  495. record.convertPromoGiftsQty = v
  496. this.dataSource.splice()
  497. },
  498. // 选择单元格
  499. selectedRowChange ({ row, isSelected, selectedRowKeys }) {
  500. // console.log(row, isSelected, selectedRowKeys);
  501. this.selectedRowKeys = selectedRowKeys
  502. if (!isSelected) {
  503. row.convertPromoGiftsQty = row.bakConvertPromoGiftsQty
  504. }
  505. },
  506. // 全选行
  507. selectedAllChange ({ isSelected, selectedRowKeys }) {
  508. this.selectedRowKeys = selectedRowKeys
  509. // 取消全选后,重置数量
  510. if (!isSelected && this.showConvertPromoGifts) {
  511. this.dataSource.filter(item => item.convertPromoGiftsQty).map(item => {
  512. item.convertPromoGiftsQty = item.bakConvertPromoGiftsQty
  513. })
  514. }
  515. },
  516. // 查询列表
  517. async searchTable () {
  518. this.selectedRowKeys = []
  519. this.disableSelectedRowKeys = []
  520. this.dataSource = []
  521. this.disabled = true
  522. this.spinning = true
  523. this.queryParam.salesBillSn = this.salesBillSn
  524. this.queryParam.showStock = true
  525. const params = this.queryParam
  526. // 所有活动接口
  527. const active = this.activeList
  528. // 是否查询正常产品
  529. const hasSearchNormal = !params.promotionFlag || params.promotionFlag == 0
  530. const proList = hasSearchNormal ? await queryAwaitDispatch({ ...params, detailPromoFlag: 0 }).then(res => res.data) : []
  531. this.hasNormalProduct = proList.length > 0 // 是否有正常产品
  532. // 没有活动时不显示正常产品标题行
  533. let listData = proList
  534. // 获取活动产品列表,查询条件未选正常产品
  535. if (params.promotionFlag != 0) {
  536. const aclist = await queryAwaitDispatch({ ...params, detailPromoFlag: 1 }).then(res => res.data)
  537. // 没用活动产品,不显示
  538. const retList = aclist.length ? [{
  539. id: 'promo-active'
  540. }, ...aclist] : []
  541. // 将活动产品数据拼接
  542. listData = aclist && aclist.length ? listData.concat(retList) : listData
  543. }
  544. this.dataSource = listData
  545. // 格式化数据
  546. let f = 0
  547. this.dataSource.map((item, i) => {
  548. const isTjRow = item.id.indexOf('promo-') >= 0
  549. if (isTjRow) { f = f - 1 }
  550. item.no = i + 1 + f
  551. const productCode = (item.productEntity && item.productEntity.code) || (item.dealerProductEntity && item.dealerProductEntity.code)
  552. const productName = (item.productEntity && item.productEntity.name) || (item.dealerProductEntity && item.dealerProductEntity.name)
  553. const productOrigCode = (item.productEntity && item.productEntity.origCode) || (item.dealerProductEntity && item.dealerProductEntity.origCode)
  554. const productOrigUnit = (item.productEntity && item.productEntity.unit) || (item.dealerProductEntity && item.dealerProductEntity.unit)
  555. item.productCode = productCode || '--'
  556. item.productName = productName || '--'
  557. item.productOrigCode = productOrigCode == ' ' ? '--' : productOrigCode
  558. item.productOrigUnit = productOrigUnit || '--'
  559. item.promoRuleSnList = item.promotionRuleList && item.promotionRuleList.map(item => item.promotionRuleSn) // 规则sn
  560. item.cancelNums = item.unpushedQty // 取消数量
  561. // 转采购额最大数量
  562. if (item.convertPromoGiftsFlag == 1) {
  563. item.maxConvertNums = item.unpushedQty + item.convertPromoGiftsQty
  564. } else {
  565. item.maxConvertNums = 0
  566. }
  567. // 转采购额数量
  568. item.bakConvertPromoGiftsQty = item.convertPromoGiftsQty
  569. // 库存为0或待下推数为0,不可添加
  570. if (!item.convertPromoGiftsQty && (!item.unpushedQty || item.unpushedQty < 0) || isTjRow) {
  571. this.disableSelectedRowKeys.push(item.id)
  572. }
  573. })
  574. this.showEmpty = this.dataSource.length <= 0
  575. this.tableData = this.dataSource
  576. this.spinning = false
  577. this.disabled = false
  578. },
  579. // 重置
  580. resetSearchForm (detailData) {
  581. this.queryParam.pushProductType = ''
  582. this.queryParam.productCode = ''
  583. this.queryParam.productName = ''
  584. this.queryParam.promotionFlag = undefined
  585. this.queryParam.brandSn = undefined
  586. this.queryParam.productTypeSn1 = ''
  587. this.queryParam.productTypeSn2 = ''
  588. this.queryParam.productTypeSn3 = ''
  589. this.queryParam.warehouseSn = undefined
  590. this.queryParam.convertPromoGiftsFlag = undefined
  591. this.productType = []
  592. this.dataSource = []
  593. this.clearSelectTable()
  594. this.searchTable()
  595. if (detailData) {
  596. this.detailData = detailData
  597. }
  598. },
  599. pageInit (salesBillSn, detailData) {
  600. this.salesBillSn = salesBillSn
  601. this.detailData = detailData
  602. // 是否转过采购单
  603. this.hasCreatePurchaseFlag()
  604. this.searchTable()
  605. },
  606. // 清空选项
  607. clearSelectTable () {
  608. this.selectedRowKeys = []
  609. },
  610. // 添加
  611. handleAdd (row) {
  612. if (row && row.productEntity && row.productEntity.productBrandName == '箭冠' && row.productEntity.productTypeName3 == '轮胎') {
  613. if (!row.lockStockQty) {
  614. this.$message.warning('锁定库存为0,不可添加!')
  615. } else {
  616. this.$emit('addProduct', [row.salesBillDetailSn])
  617. }
  618. } else {
  619. if (row.stockQty > 0) { // 可用库存大于0才可添加
  620. this.$emit('addProduct', [row.salesBillDetailSn])
  621. } else {
  622. this.$message.warning('库存为0,不可添加!')
  623. }
  624. }
  625. },
  626. // 批量转采购额
  627. handlePlPurchase () {
  628. const _this = this
  629. const chooseList = this.selectedRowKeys
  630. if (chooseList.length == 0) {
  631. _this.$message.warning('请先选择产品!')
  632. return
  633. }
  634. const chooseRow = this.dataSource.filter(item => chooseList.includes(item.id) && item.convertPromoGiftsFlag == 1)
  635. const noChooseRow = this.dataSource.filter(item => chooseList.includes(item.id) && !item.convertPromoGiftsFlag)
  636. const obj = []
  637. const noObj = []
  638. noChooseRow && noChooseRow.map(item => {
  639. noObj.push(item.productCode)
  640. })
  641. chooseRow && chooseRow.map(item => {
  642. obj.push({
  643. 'convertPromoGiftsQty': item.convertPromoGiftsQty,
  644. 'salesBillDetailSn': item.salesBillDetailSn
  645. })
  646. })
  647. if (obj.length) {
  648. this.$confirm({
  649. title: '提示',
  650. content: <div><div style="text-align:center;padding:10px 0;font-weight:bold;">确定将选中的促销产品转成采购额吗?</div>{noObj.length ? <div style="text-align:center;"><div>总共选择了 {chooseList.length} 个产品,其中 {obj.length} 个产品可转采购额。</div><div style="color:red;"> 产品 ({noObj.toString()}) 不可转采购额!</div></div> : ''}<div style="font-size:12px;color:#999;padding:10px 0;text-align:center;">
  651. 当该销售单完结后,可将采购额转成费用报销单。</div></div>,
  652. centered: true,
  653. closable: true,
  654. class: 'confirm-center',
  655. onOk () {
  656. _this.$emit('convertPromoGifts', obj)
  657. }
  658. })
  659. } else {
  660. _this.$message.warning('所选产品都不可转采购额!')
  661. }
  662. },
  663. // 批量添加
  664. handlePlAdd () {
  665. const _this = this
  666. const chooseList = this.selectedRowKeys
  667. if (chooseList.length == 0) {
  668. _this.$message.warning('请先选择产品!')
  669. return
  670. }
  671. // 库存为0的产品,不包括箭冠轮胎产品
  672. const noStockRow = this.dataSource.filter(item => chooseList.includes(item.id) && !item.stockQty && item.productEntity && item.productEntity.productBrandName != '箭冠' && item.productEntity.productTypeName3 != '轮胎')
  673. // 锁定库存为0的产品,只判断箭冠轮胎产品
  674. const noLockStockRow = this.dataSource.filter(item => chooseList.includes(item.id) && item.productEntity && item.productEntity.productBrandName == '箭冠' && item.productEntity.productTypeName3 == '轮胎' && !item.lockStockQty)
  675. // 库存为0产品编码列表
  676. const noObj = []
  677. const noObjSn = []
  678. noStockRow && noStockRow.map(item => {
  679. noObj.push(item.productCode)
  680. noObjSn.push(item.salesBillDetailSn)
  681. })
  682. // 锁定库存为0的产品
  683. const noLockObj = []
  684. const noLockObjSn = []
  685. noLockStockRow && noLockStockRow.map(item => {
  686. noLockObj.push(item.productCode)
  687. noLockObjSn.push(item.salesBillDetailSn)
  688. })
  689. // 可添加产品,不包括库存未0和箭冠轮胎锁定库存为0的产品
  690. const chooseRow = this.dataSource.filter(item => {
  691. return chooseList.includes(item.id) && !noObjSn.includes(item.salesBillDetailSn) && !noLockObjSn.includes(item.salesBillDetailSn)
  692. })
  693. // 可添加产品sn列表
  694. const obj = []
  695. chooseRow && chooseRow.map(item => {
  696. obj.push(item.salesBillDetailSn)
  697. })
  698. if (obj.length) {
  699. this.$confirm({
  700. title: '提示',
  701. content: <div><div style="text-align:center;padding:10px 0;font-weight:bold;">确认要批量添加到待下推列表吗?</div>{(noObj.length || noLockObj.length) ? <div><div>总共选择了 {chooseList.length} 个产品,其中 {obj.length} 个产品可添加。</div>{noObj.length ? <div>产品 ({noObj.toString()}) 因库存为0不可添加!</div> : ''}</div> : ''}<div>{noLockObj.length ? <div>产品 ({noLockObj.toString()}) 因锁定库存为0不可添加!</div> : ''}</div></div>,
  702. centered: true,
  703. closable: true,
  704. class: 'confirm-center',
  705. onOk () {
  706. _this.$emit('addProduct', obj)
  707. }
  708. })
  709. } else {
  710. _this.$message.warning(noLockObj.length ? '所选产品锁定库存都为0,不可添加!' : '所选产品库存都为0,不可添加!')
  711. }
  712. },
  713. // 整单取消
  714. handleAllCancel () {
  715. const _this = this
  716. this.$confirm({
  717. title: '提示',
  718. content: '确定整单取消订单?',
  719. centered: true,
  720. closable: true,
  721. onOk () {
  722. _this.$emit('cancelAll')
  723. }
  724. })
  725. },
  726. // 批量取消
  727. handlePlCancel () {
  728. const _this = this
  729. const chooseList = this.selectedRowKeys
  730. if (chooseList.length == 0) {
  731. _this.$message.warning('请先选择产品!')
  732. return
  733. }
  734. const chooseRow = this.dataSource.filter(item => chooseList.includes(item.id) && item.id.indexOf('promo-') < 0)
  735. const hasActive = chooseRow && chooseRow.filter(item => item.promotionFlag != 0)
  736. if (hasActive.length > 0) {
  737. _this.$message.warning('参与促销的产品只可进行整单取消!')
  738. return
  739. }
  740. const obj = []
  741. chooseRow && chooseRow.map(item => {
  742. obj.push({
  743. 'cancelQty': item.cancelNums,
  744. 'salesBillDetailSn': item.salesBillDetailSn
  745. })
  746. })
  747. this.$emit('cancelProduct', obj)
  748. },
  749. // 确认整单转采购单
  750. confirPurchaseModal () {
  751. this.loading = true
  752. getCreatePurchaseFlag({ salesBillSn: this.salesBillSn }).then(res => {
  753. if (res.status == '200') {
  754. // 没有转过
  755. if (res.data == 0) {
  756. this.showPurchaseModal()
  757. } else {
  758. // 转过,弹确认框
  759. const _this = this
  760. this.$confirm({
  761. title: '提示',
  762. content: '已转过采购单,是否再次转单?',
  763. centered: true,
  764. closable: true,
  765. onOk () {
  766. _this.showPurchaseModal()
  767. }
  768. })
  769. }
  770. }
  771. this.loading = false
  772. })
  773. },
  774. // 打开转采购单弹框
  775. showPurchaseModal () {
  776. this.openPurchaseModal = true
  777. this.$refs.purchaseModal.setDetail(this.detailData)
  778. },
  779. // 是否转过采购单
  780. hasCreatePurchaseFlag () {
  781. getCreatePurchaseFlag({ salesBillSn: this.salesBillSn }).then(res => {
  782. this.showLockStockQty = res.data && res.data == 1
  783. })
  784. }
  785. }
  786. }
  787. </script>
  788. <style lang="less">
  789. .empty-data-0{
  790. color: #999;
  791. text-align: center;
  792. padding: 10px;
  793. position: absolute;
  794. bottom: 0;
  795. width: 100%;
  796. }
  797. .ve-table-body-td{
  798. .active-title{
  799. display: flex;
  800. align-items: center;
  801. justify-content: space-between;
  802. padding: 10px;
  803. background: #f3f8fa;
  804. }
  805. }
  806. .ve-table .ve-table-container .ve-table-content-wrapper table.ve-table-content tbody.ve-table-body tr.ve-table-body-tr td.table-body-cell-no,
  807. .ve-table .ve-table-container .ve-table-content-wrapper table.ve-table-content tbody.ve-table-body tr.ve-table-expand-tr td.table-body-cell-no{
  808. padding: 0;
  809. }
  810. .ve-table .ve-table-container .ve-table-content-wrapper{
  811. border-bottom: 1px solid #ddd;
  812. }
  813. </style>