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