queryPart.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <div class="productInfoList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :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="6" :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="6" :sm="24">
  18. <a-form-item label="是否促销品">
  19. <v-select
  20. code="FLAG"
  21. id="productInfoList-promotionFlag"
  22. v-model="queryParam.promotionFlag"
  23. allowClear
  24. placeholder="请选择是否"
  25. ></v-select>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="类型">
  30. <a-select v-model.trim="queryParam.ptype" :dropdownMatchSelectWidth="false" >
  31. <a-select-option value="0">
  32. 全部产品
  33. </a-select-option>
  34. <a-select-option value="1">
  35. 剩余待下推数量>0的产品
  36. </a-select-option>
  37. <a-select-option value="2">
  38. 可全部下推的产品
  39. </a-select-option>
  40. <a-select-option value="3">
  41. 不可全部下推的产品
  42. </a-select-option>
  43. </a-select>
  44. </a-form-item>
  45. </a-col>
  46. <a-col :md="6" :sm="24">
  47. <a-form-item label="出库仓库">
  48. <chooseWarehouse ref="warehouse" v-model="queryParam.warehouseSn"></chooseWarehouse>
  49. </a-form-item>
  50. </a-col>
  51. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  52. <a-button type="primary" class="button-info" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  53. <a-button style="margin-left: 5px" @click="resetSearchForm" id="productInfoList-reset">重置</a-button>
  54. </a-col>
  55. </a-row>
  56. </a-form>
  57. </div>
  58. <!-- alert -->
  59. <div style="margin-bottom: 10px;display: flex;" v-if="detailData">
  60. <div>
  61. <a-button type="primary" :disabled="newLoading" class="button-info" @click="handlePlAdd">批量添加</a-button>
  62. <a-button type="danger" :disabled="newLoading" class="button-error" @click="handlePlCancel">批量取消</a-button>
  63. <!-- <a-button type="default" :disabled="newLoading" @click="handleOneDispatch">有货一键下推</a-button> -->
  64. </div>
  65. <div style="padding-left: 20px;">
  66. 总销售数量:<strong>{{ detailData&&(detailData.totalQty || detailData.totalQty==0) ? detailData.totalQty : '--' }}</strong>;
  67. 已取消数量:<strong>{{ detailData&&(detailData.totalCancelQty || detailData.totalCancelQty==0) ? detailData.totalCancelQty : '--' }}</strong>;
  68. 已下推数量:<strong>{{ detailData&&(detailData.totalPushedQty || detailData.totalPushedQty==0) ? detailData.totalPushedQty : '--' }}</strong>;
  69. 待下推数量:<strong>{{ detailData&&(detailData.totalUnpushedQty || detailData.totalUnpushedQty==0) ? detailData.totalUnpushedQty : '--' }}</strong>;<br/>
  70. <span v-if="$hasPermissions('B_salesDispatch_salesPrice')">总售价:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? toThousands(detailData.totalAmount) : '--' }}</strong>;</span>
  71. <span v-if="$hasPermissions('B_salesDispatch_costPrice')">总成本:<strong>{{ detailData&&(detailData.totalCost || detailData.totalCost==0) ? toThousands(detailData.totalCost) : '--' }}</strong>;</span>
  72. <span v-if="$hasPermissions('B_salesDispatch_costPrice')&&$hasPermissions('B_salesDispatch_salesPrice')">总毛利:<strong>{{ detailData&&(detailData.grossProfit || detailData.grossProfit==0) ? toThousands(detailData.grossProfit) : '--' }}</strong>;</span>
  73. <span v-if="$hasPermissions('B_salesDispatch_salesPrice')">已取消金额:<strong>{{ detailData&&(detailData.totalCancelAmount || detailData.totalCancelAmount==0) ? toThousands(detailData.totalCancelAmount) : '--' }}</strong>;</span>
  74. <span v-if="$hasPermissions('B_salesDispatch_salesPrice')">已下推金额:<strong>{{ detailData&&(detailData.totalPushedAmount || detailData.totalPushedAmount==0) ? toThousands(detailData.totalPushedAmount) :'--' }}</strong>;</span>
  75. <span v-if="$hasPermissions('B_salesDispatch_salesPrice')">待下推金额:<strong>{{ detailData&&(detailData.totalUnpushedAmount || detailData.totalUnpushedAmount==0) ? toThousands(detailData.totalUnpushedAmount) : '--' }}</strong>;</span>
  76. </div>
  77. </div>
  78. <!-- 列表 -->
  79. <s-table
  80. class="sTable"
  81. ref="table"
  82. size="small"
  83. :rowKey="(record) => record.id"
  84. :row-selection="{ columnWidth: 40, getCheckboxProps:record =>({props: { disabled: record.surplusQty<=0 }})}"
  85. @rowSelection="rowSelectionFun"
  86. :columns="columns"
  87. :showPagination="false"
  88. :data="loadData"
  89. :scroll="{ y: 300 }"
  90. :defaultLoadData="false"
  91. bordered>
  92. <!-- 取消数量 -->
  93. <template slot="nums" slot-scope="text, record">
  94. <div v-if="record.surplusQty>0" @dblclick.stop>
  95. <a-input-number
  96. size="small"
  97. v-model="record.cancelNums"
  98. :precision="0"
  99. :min="0"
  100. :max="record.surplusQty"
  101. style="width: 100%;"
  102. placeholder="请输入" />
  103. </div>
  104. <div v-else>--</div>
  105. </template>
  106. <!-- 产品编码 -->
  107. <template slot="productCode" slot-scope="text, record">
  108. <a-badge count="促" v-if="record.promotionFlag == 1">
  109. <div style="padding-right: 15px;">{{ text }}</div>
  110. </a-badge>
  111. <span v-else>{{ text }}</span>
  112. </template>
  113. <!-- 操作 -->
  114. <template slot="action" slot-scope="text, record">
  115. <a-button
  116. size="small"
  117. type="link"
  118. class="button-info"
  119. :loading="newLoading"
  120. @click="handleAdd(record)"
  121. v-if="record.surplusQty>0"
  122. id="productInfoList-edit-btn">添加</a-button>
  123. <span v-else>--</span>
  124. </template>
  125. </s-table>
  126. </div>
  127. </template>
  128. <script>
  129. import { commonMixin } from '@/utils/mixin'
  130. import { salesDetailAllStockList } from '@/api/salesDetail'
  131. import { STable, VSelect } from '@/components'
  132. import chooseWarehouse from '@/views/common/chooseWarehouse'
  133. export default {
  134. name: 'QueryPart',
  135. mixins: [commonMixin],
  136. components: { STable, VSelect, chooseWarehouse },
  137. props: {
  138. newLoading: Boolean
  139. },
  140. watch: {
  141. data (newValue, oldValue) {
  142. this.resetSearchForm()
  143. }
  144. },
  145. data () {
  146. return {
  147. advanced: true, // 高级搜索 展开/关闭
  148. showSetting: false, // 设置弹框
  149. productType: [],
  150. salesBillSn: '',
  151. detailData: null,
  152. queryParam: {
  153. ptype: '0', // 类型
  154. productCode: '', // 产品编码
  155. productName: '', // 产品名称
  156. promotionFlag: undefined, // 是否促销品
  157. brandSn: undefined, // 产品品牌
  158. productTypeSn1: '', // 产品一级分类
  159. productTypeSn2: '', // 产品二级分类
  160. productTypeSn3: '', // 产品三级分类
  161. salesBillSn: '',
  162. warehouseSn: undefined
  163. },
  164. disabled: false, // 查询、重置按钮是否可操作
  165. // 加载数据方法 必须为 Promise 对象
  166. loadData: parameter => {
  167. this.disabled = true
  168. this.queryParam.salesBillSn = this.salesBillSn
  169. return salesDetailAllStockList(Object.assign(parameter, this.queryParam)).then(res => {
  170. let data
  171. if (res.status == 200) {
  172. data = res.data
  173. if (data) {
  174. // 根据类型过滤数据
  175. data = data.filter(item => {
  176. if (this.queryParam.ptype == '1') {
  177. return item != null && item.surplusQty > 0
  178. }
  179. if (this.queryParam.ptype == '2') {
  180. return item != null && item.surplusQty > 0 && item.surplusQty <= item.stockQty
  181. }
  182. if (this.queryParam.ptype == '3') {
  183. return item != null && item.surplusQty > item.stockQty
  184. }
  185. if (this.queryParam.ptype == '0') {
  186. return item != null
  187. }
  188. })
  189. // 增加编号
  190. const no = 0
  191. for (var i = 0; i < data.length; i++) {
  192. data[i].no = no + i + 1
  193. data[i].cancelNums = data[i].surplusQty
  194. }
  195. this.disabled = false
  196. }
  197. }
  198. return data
  199. })
  200. },
  201. rowSelectionInfo: null
  202. }
  203. },
  204. computed: {
  205. columns () {
  206. const arr = [
  207. // { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  208. { title: '产品编码', dataIndex: 'productEntity.code', scopedSlots: { customRender: 'productCode' }, width: '14%', align: 'center' },
  209. { title: '产品名称', dataIndex: 'productEntity.name', width: '14%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  210. { title: '原厂编码', dataIndex: 'productEntity.origCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  211. // { title: '销售价', dataIndex: 'price', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  212. // { title: '成本价', dataIndex: 'showCost', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  213. { title: '出库仓库', dataIndex: 'warehouseName', width: '8%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  214. { title: '单位', dataIndex: 'productEntity.unit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  215. { title: '可用库存', dataIndex: 'stockQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  216. { title: '销售数量', dataIndex: 'qty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  217. { title: '已取消', dataIndex: 'cancelQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  218. { title: '已下推', dataIndex: 'pushedQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  219. { title: '待下推数量', dataIndex: 'surplusQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  220. { title: '取消数量', dataIndex: 'cancelNums', scopedSlots: { customRender: 'nums' }, width: '7%', align: 'center' },
  221. { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  222. ]
  223. if (this.$hasPermissions('B_salesDispatch_salesPrice')) { // 售价权限
  224. arr.splice(3, 0, { title: '销售价', dataIndex: 'price', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  225. }
  226. if (this.$hasPermissions('B_salesDispatch_costPrice')) {
  227. const ind = this.$hasPermissions('B_salesDispatch_salesPrice') ? 4 : 3
  228. arr.splice(ind, 0, { title: '成本价', dataIndex: 'showCost', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  229. }
  230. return arr
  231. }
  232. },
  233. methods: {
  234. // 表格选中项
  235. rowSelectionFun (obj) {
  236. this.rowSelectionInfo = obj || null
  237. },
  238. // 类型变化,过滤列表
  239. handlePtypeChange () {},
  240. // 重置
  241. resetSearchForm () {
  242. this.queryParam.ptype = '0'
  243. this.queryParam.productCode = ''
  244. this.queryParam.productName = ''
  245. this.queryParam.promotionFlag = undefined
  246. this.queryParam.brandSn = undefined
  247. this.queryParam.productTypeSn1 = ''
  248. this.queryParam.productTypeSn2 = ''
  249. this.queryParam.productTypeSn3 = ''
  250. this.queryParam.warehouseSn = undefined
  251. this.productType = []
  252. this.$refs.table.refresh(true)
  253. },
  254. pageInit (salesBillSn, detailData) {
  255. this.salesBillSn = salesBillSn
  256. this.detailData = detailData
  257. this.$refs.table.clearSelected()
  258. this.resetSearchForm()
  259. },
  260. clearTable () {
  261. this.rowSelectionInfo = null
  262. this.$refs.table.clearSelected()
  263. },
  264. // 刷新当前页面
  265. resetCurForm () {
  266. this.$refs.table.clearSelected() // 清空表格选中项
  267. this.$refs.table.refresh()
  268. },
  269. // 添加
  270. handleAdd (row) {
  271. if (row.stockQty > 0) { // 可用库存大于0才可添加
  272. this.$emit('addProduct', [row.salesBillDetailSn])
  273. } else {
  274. this.$message.warning('库存为0,不可添加!')
  275. }
  276. },
  277. // 批量添加
  278. handlePlAdd () {
  279. const _this = this
  280. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  281. _this.$message.warning('请先选择产品!')
  282. return
  283. }
  284. const obj = []
  285. _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
  286. if (item.stockQty > 0) {
  287. obj.push(item.salesBillDetailSn)
  288. }
  289. })
  290. if (obj.length < 1) {
  291. this.$message.warning('所选产品库存为0,不可添加!')
  292. return
  293. }
  294. this.$confirm({
  295. title: '提示',
  296. content: '确认要批量添加到待下推列表吗?',
  297. centered: true,
  298. closable: true,
  299. onOk () {
  300. _this.$emit('addProduct', obj)
  301. }
  302. })
  303. },
  304. // 批量取消
  305. handlePlCancel () {
  306. const _this = this
  307. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  308. _this.$message.warning('请先选择产品!')
  309. return
  310. }
  311. const obj = []
  312. _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
  313. obj.push({
  314. 'cancelQty': item.cancelNums,
  315. 'salesBillDetailSn': item.salesBillDetailSn,
  316. 'salesBillSn': this.salesBillSn
  317. })
  318. })
  319. this.$emit('cancelProduct', obj)
  320. },
  321. // 一键下推
  322. handleOneDispatch () {
  323. this.$emit('oneDispatch')
  324. },
  325. // 产品分类 change
  326. changeProductType (val, opt) {
  327. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  328. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  329. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  330. }
  331. }
  332. }
  333. </script>