queryPart.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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 allowClear v-model.trim="queryParam.ptype" >
  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. 总售价:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? detailData.totalAmount : '--' }}</strong>;
  67. <span v-if="$hasPermissions('B_isShowCost')">总成本:<strong>{{ detailData&&(detailData.totalCost || detailData.totalCost==0) ? detailData.totalCost : '--' }}</strong>;</span>
  68. 总毛利:<strong>{{ detailData&&(detailData.grossProfit || detailData.grossProfit==0) ? detailData.grossProfit : '--' }}</strong>;
  69. 已取消金额:<strong>{{ detailData&&(detailData.totalCancelAmount || detailData.totalCancelAmount==0) ? detailData.totalCancelAmount : '--' }}</strong>;
  70. 已下推金额:<strong>{{ detailData&&(detailData.totalPushedAmount || detailData.totalPushedAmount==0) ? detailData.totalPushedAmount :'--' }}</strong>;
  71. 待下推金额:<strong>{{ detailData&&(detailData.totalUnpushedAmount || detailData.totalUnpushedAmount==0) ? detailData.totalUnpushedAmount : '--' }}</strong>;
  72. </div>
  73. </a-alert>
  74. <!-- 列表 -->
  75. <s-table
  76. class="sTable"
  77. ref="table"
  78. size="small"
  79. :row-selection="{
  80. selectedRowKeys: selectedRowKeys,
  81. onChange: onChange,
  82. onSelect: onSelectChange,
  83. onSelectAll: onSelectAllChange,
  84. getCheckboxProps:record =>({props: {
  85. disabled: record.surplusQty<=0,
  86. }})
  87. }"
  88. :rowKey="(record) => record.id"
  89. :columns="columns"
  90. :showPagination="false"
  91. :data="loadData"
  92. :scroll="{ y: 300 }"
  93. :defaultLoadData="false"
  94. bordered>
  95. <!-- 取消数量 -->
  96. <template slot="nums" slot-scope="text, record">
  97. <div v-if="record.surplusQty>0" @dblclick.stop>
  98. <a-input-number
  99. size="small"
  100. v-model="record.cancelNums"
  101. :precision="0"
  102. :min="0"
  103. :max="999999"
  104. style="width: 100%;"
  105. placeholder="请输入" />
  106. </div>
  107. <div v-else>--</div>
  108. </template>
  109. <!-- 产品编码 -->
  110. <template slot="productCode" slot-scope="text, record">
  111. <a-badge count="促" v-if="record.promotionFlag == 1">
  112. <div style="padding-right: 15px;">{{ text }}</div>
  113. </a-badge>
  114. <span v-else>{{ text }}</span>
  115. </template>
  116. <!-- 操作 -->
  117. <template slot="action" slot-scope="text, record">
  118. <a-button
  119. size="small"
  120. type="primary"
  121. class="button-info"
  122. :loading="newLoading"
  123. @click="handleAdd(record)"
  124. v-if="record.surplusQty>0"
  125. id="productInfoList-edit-btn">添加</a-button>
  126. <span v-else>--</span>
  127. </template>
  128. </s-table>
  129. </div>
  130. </template>
  131. <script>
  132. import { salesDetailAllStockList } from '@/api/salesDetail'
  133. import { STable, VSelect } from '@/components'
  134. export default {
  135. name: 'QueryPart',
  136. components: { STable, VSelect },
  137. props: {
  138. newLoading: Boolean
  139. },
  140. watch: {
  141. data (newValue, oldValue) {
  142. console.log(newValue)
  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. },
  164. disabled: false, // 查询、重置按钮是否可操作
  165. selectedRowKeys: [], // Check here to configure the default column
  166. selectedRows: [],
  167. // 加载数据方法 必须为 Promise 对象
  168. loadData: parameter => {
  169. this.disabled = true
  170. this.queryParam.salesBillSn = this.salesBillSn
  171. return salesDetailAllStockList(Object.assign(parameter, this.queryParam)).then(res => {
  172. let 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. return data
  198. })
  199. }
  200. }
  201. },
  202. computed: {
  203. columns () {
  204. const arr = [
  205. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  206. { title: '产品编码', dataIndex: 'productEntity.code', scopedSlots: { customRender: 'productCode' }, width: '12%', align: 'center' },
  207. { title: '产品名称', dataIndex: 'productEntity.name', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  208. { title: '原厂编码', dataIndex: 'productEntity.origCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  209. { title: '销售价', dataIndex: 'price', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  210. { title: '单位', dataIndex: 'productEntity.unit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  211. { title: '可用库存', dataIndex: 'stockQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  212. { title: '销售数量', dataIndex: 'qty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  213. { title: '已取消', dataIndex: 'cancelQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  214. { title: '已下推', dataIndex: 'pushedQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  215. { title: '剩余待下推', dataIndex: 'surplusQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  216. { title: '取消数量', dataIndex: 'cancelNums', scopedSlots: { customRender: 'nums' }, width: '7%', align: 'center' },
  217. { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  218. ]
  219. if (this.$hasPermissions('B_isShowCost')) {
  220. arr.splice(4, 0, { title: '成本价', dataIndex: 'showCost', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  221. }
  222. return arr
  223. }
  224. },
  225. methods: {
  226. onChange (selectedRowKeys, selectedRows) {
  227. this.selectedRowKeys = selectedRowKeys
  228. },
  229. onSelectChange (record, selected, selectedRows, nativeEvent) {
  230. if (selected) { // 选择
  231. this.selectedRows.push(record)
  232. } else { // 取消
  233. this.selectedRows = selectedRows
  234. }
  235. },
  236. // 本页全选/取消全选
  237. onSelectAllChange (selected, selectedRows, changeRows) {
  238. const _this = this
  239. if (selected) { // 选择
  240. this.selectedRows = [...this.selectedRows, ...changeRows]
  241. } else { // 取消
  242. const arrId = []
  243. this.selectedRows.map((item, index) => {
  244. this.selectedRows.map((subItem, ind) => {
  245. if (item.id == subItem.id) {
  246. arrId.push(index)
  247. }
  248. })
  249. })
  250. arrId.map((item, index) => {
  251. _this.selectedRows = _this.selectedRows.slice(item, item + 1)
  252. })
  253. }
  254. },
  255. // 类型变化,过滤列表
  256. handlePtypeChange () {
  257. },
  258. // 重置
  259. resetSearchForm () {
  260. this.queryParam.productCode = ''
  261. this.queryParam.productName = ''
  262. this.queryParam.promotionFlag = undefined
  263. this.queryParam.brandSn = undefined
  264. this.queryParam.productTypeSn1 = ''
  265. this.queryParam.productTypeSn2 = ''
  266. this.queryParam.productTypeSn3 = ''
  267. this.productType = []
  268. this.$refs.table.refresh(true)
  269. },
  270. pageInit (salesBillSn, detailData) {
  271. this.salesBillSn = salesBillSn
  272. this.detailData = detailData
  273. this.resetSearchForm()
  274. },
  275. // 刷新当前页面
  276. resetCurForm () {
  277. this.selectedRowKeys = []
  278. this.selectedRows = []
  279. this.$refs.table.refresh()
  280. },
  281. // 添加
  282. handleAdd (row) {
  283. if (row.stockQty > 0) { // 可用库存大于0才可添加
  284. this.$emit('addProduct', [row.salesBillDetailSn])
  285. } else {
  286. this.$message.warning('库存为0,不可添加!')
  287. }
  288. },
  289. // 批量添加
  290. handlePlAdd () {
  291. const _this = this
  292. if (_this.selectedRowKeys.length < 1) {
  293. _this.$message.warning('请在选择产品!')
  294. return
  295. }
  296. const obj = []
  297. _this.selectedRows.map(item => {
  298. if (item.stockQty > 0) {
  299. obj.push(item.salesBillDetailSn)
  300. }
  301. })
  302. if (obj.length < 1) {
  303. this.$message.warning('所选产品库存为0,不可添加!')
  304. return
  305. }
  306. this.$confirm({
  307. title: '提示',
  308. content: '确认要批量添加到待下推列表吗?',
  309. centered: true,
  310. closable: true,
  311. onOk () {
  312. _this.$emit('addProduct', obj)
  313. }
  314. })
  315. },
  316. // 批量取消
  317. handlePlCancel () {
  318. const _this = this
  319. if (_this.selectedRowKeys.length < 1) {
  320. _this.$message.warning('请在选择产品!')
  321. return
  322. }
  323. const obj = []
  324. _this.selectedRows.map(item => {
  325. obj.push({
  326. 'cancelQty': item.cancelNums,
  327. 'salesBillDetailSn': item.salesBillDetailSn
  328. })
  329. })
  330. this.$emit('cancelProduct', obj)
  331. },
  332. // 一键下推
  333. handleOneDispatch () {
  334. const _this = this
  335. this.$confirm({
  336. title: '提示',
  337. content: '确定后,所有有货的产品将自动添加到待下推列表,确定要进行有货一键下推吗?',
  338. centered: true,
  339. closable: true,
  340. onOk () {
  341. _this.$emit('oneDispatch')
  342. }
  343. })
  344. },
  345. // 产品分类 change
  346. changeProductType (val, opt) {
  347. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  348. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  349. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  350. }
  351. }
  352. }
  353. </script>