queryPart.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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. :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="record.surplusQty"
  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
  173. if (res.status == 200) {
  174. data = res.data
  175. if (data) {
  176. // 根据类型过滤数据
  177. data = data.filter(item => {
  178. if (this.queryParam.ptype == '1') {
  179. return item != null && item.surplusQty > 0
  180. }
  181. if (this.queryParam.ptype == '2') {
  182. return item != null && item.surplusQty > 0 && item.surplusQty <= item.stockQty
  183. }
  184. if (this.queryParam.ptype == '3') {
  185. return item != null && item.surplusQty > item.stockQty
  186. }
  187. if (this.queryParam.ptype == '0') {
  188. return item != null
  189. }
  190. })
  191. // 增加编号
  192. const no = 0
  193. for (var i = 0; i < data.length; i++) {
  194. data[i].no = no + i + 1
  195. data[i].cancelNums = data[i].surplusQty
  196. }
  197. this.disabled = false
  198. }
  199. }
  200. return data
  201. })
  202. }
  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: '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_isShowPrice')) { // 售价权限
  224. arr.splice(3, 0, { title: '销售价', dataIndex: 'price', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  225. }
  226. if (this.$hasPermissions('B_isShowCost')) {
  227. const ind = this.$hasPermissions('B_isShowPrice') ? 4 : 3
  228. arr.splice(ind, 0, { title: '成本价', dataIndex: 'showCost', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  229. }
  230. return arr
  231. }
  232. },
  233. methods: {
  234. onChange (selectedRowKeys, selectedRows) {
  235. this.selectedRowKeys = selectedRowKeys
  236. },
  237. onSelectChange (record, selected, selectedRows, nativeEvent) {
  238. if (selected) { // 选择
  239. this.selectedRows.push(record)
  240. } else { // 取消
  241. this.selectedRows = selectedRows
  242. }
  243. },
  244. // 本页全选/取消全选
  245. onSelectAllChange (selected, selectedRows, changeRows) {
  246. const _this = this
  247. if (selected) { // 选择
  248. this.selectedRows = [...this.selectedRows, ...changeRows]
  249. } else { // 取消
  250. const arrId = []
  251. this.selectedRows.map((item, index) => {
  252. this.selectedRows.map((subItem, ind) => {
  253. if (item.id == subItem.id) {
  254. arrId.push(index)
  255. }
  256. })
  257. })
  258. arrId.map((item, index) => {
  259. _this.selectedRows = _this.selectedRows.slice(item, item + 1)
  260. })
  261. }
  262. },
  263. // 类型变化,过滤列表
  264. handlePtypeChange () {
  265. },
  266. // 重置
  267. resetSearchForm () {
  268. this.queryParam.ptype = '0'
  269. this.queryParam.productCode = ''
  270. this.queryParam.productName = ''
  271. this.queryParam.promotionFlag = undefined
  272. this.queryParam.brandSn = undefined
  273. this.queryParam.productTypeSn1 = ''
  274. this.queryParam.productTypeSn2 = ''
  275. this.queryParam.productTypeSn3 = ''
  276. this.productType = []
  277. this.$refs.table.refresh(true)
  278. },
  279. pageInit (salesBillSn, detailData) {
  280. this.salesBillSn = salesBillSn
  281. this.detailData = detailData
  282. this.resetSearchForm()
  283. },
  284. // 刷新当前页面
  285. resetCurForm () {
  286. this.selectedRowKeys = []
  287. this.selectedRows = []
  288. this.$refs.table.refresh()
  289. },
  290. // 添加
  291. handleAdd (row) {
  292. if (row.stockQty > 0) { // 可用库存大于0才可添加
  293. this.$emit('addProduct', [row.salesBillDetailSn])
  294. } else {
  295. this.$message.warning('库存为0,不可添加!')
  296. }
  297. },
  298. // 批量添加
  299. handlePlAdd () {
  300. const _this = this
  301. if (_this.selectedRowKeys.length < 1) {
  302. _this.$message.warning('请在选择产品!')
  303. return
  304. }
  305. const obj = []
  306. _this.selectedRows.map(item => {
  307. if (item.stockQty > 0) {
  308. obj.push(item.salesBillDetailSn)
  309. }
  310. })
  311. if (obj.length < 1) {
  312. this.$message.warning('所选产品库存为0,不可添加!')
  313. return
  314. }
  315. this.$confirm({
  316. title: '提示',
  317. content: '确认要批量添加到待下推列表吗?',
  318. centered: true,
  319. closable: true,
  320. onOk () {
  321. _this.$emit('addProduct', obj)
  322. }
  323. })
  324. },
  325. // 批量取消
  326. handlePlCancel () {
  327. const _this = this
  328. if (_this.selectedRowKeys.length < 1) {
  329. _this.$message.warning('请在选择产品!')
  330. return
  331. }
  332. const obj = []
  333. _this.selectedRows.map(item => {
  334. obj.push({
  335. 'cancelQty': item.cancelNums,
  336. 'salesBillDetailSn': item.salesBillDetailSn
  337. })
  338. })
  339. this.$emit('cancelProduct', obj)
  340. },
  341. // 一键下推
  342. handleOneDispatch () {
  343. const _this = this
  344. this.$confirm({
  345. title: '提示',
  346. content: '确定后,所有有货的产品将自动添加到待下推列表,确定要进行有货一键下推吗?',
  347. centered: true,
  348. closable: true,
  349. onOk () {
  350. _this.$emit('oneDispatch')
  351. }
  352. })
  353. },
  354. // 产品分类 change
  355. changeProductType (val, opt) {
  356. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  357. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  358. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  359. }
  360. }
  361. }
  362. </script>