queryPart.vue 14 KB

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