queryPart.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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" v-if="grabFlag == 1">
  8. <a-form-item label="审核时间">
  9. <rangeDate ref="rangeDate" @change="dateChange" />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="产品编码">
  14. <a-input id="productInfoList-productCode" 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. <a-input id="productInfoList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  20. </a-form-item>
  21. </a-col>
  22. <template v-if="advanced && grabFlag == 1">
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="销售单号">
  25. <a-input id="productInfoList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  26. </a-form-item>
  27. </a-col>
  28. </template>
  29. <a-col :md="6" :sm="24" style="margin-bottom: 10px">
  30. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  31. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
  32. <a @click="advanced=!advanced" style="margin:0 15px 0 8px" v-if="grabFlag == 1">
  33. {{ advanced ? '收起' : '展开' }}
  34. <a-icon :type="advanced ? 'up' : 'down'"/>
  35. </a>
  36. </a-col>
  37. </a-row>
  38. </a-form>
  39. </div>
  40. <!-- 列表 -->
  41. <s-table
  42. class="sTable"
  43. ref="table"
  44. size="small"
  45. :rowKey="(record) => record.id"
  46. :columns="columns"
  47. :data="loadData"
  48. :defaultLoadData="false"
  49. :pageSize="10"
  50. :scroll="{ y: 149 }"
  51. bordered>
  52. <!-- 价格 -->
  53. <template slot="price" slot-scope="text, record">
  54. <span v-if="grabFlag==1">{{ text }}</span>
  55. <div v-else>
  56. <a-input-number
  57. size="small"
  58. v-model="record.salePrice"
  59. :precision="2"
  60. :min="0"
  61. :max="999999"
  62. placeholder="请输入"
  63. style="width: 100%;" />
  64. </div>
  65. </template>
  66. <span slot="customTitle">
  67. 操作
  68. <!-- <a-popover>
  69. <template slot="content">
  70. 双击列表配件可快速选中添加
  71. </template>
  72. <a-icon type="question-circle" theme="twoTone" />
  73. </a-popover> -->
  74. </span>
  75. <!-- 本次退货数量 -->
  76. <template slot="returnQty" slot-scope="text, record">
  77. <a-input-number
  78. size="small"
  79. v-model="record.returnQty"
  80. :precision="0"
  81. :min="0"
  82. :max="record.qty-record.hasReturnQty"
  83. placeholder="请输入"
  84. style="width: 100%;"
  85. v-if="(grabFlag==1)&&(record.qty!=record.hasReturnQty)||grabFlag==0"
  86. />
  87. <span v-else>--</span>
  88. </template>
  89. <!-- 废品数量 -->
  90. <template slot="celQty" slot-scope="text, record">
  91. <a-input-number
  92. size="small"
  93. v-model="record.celQty"
  94. :precision="0"
  95. :min="0"
  96. :max="record.returnQty"
  97. placeholder="请输入"
  98. style="width: 100%;"
  99. v-if="(grabFlag==1)&&(record.qty!=record.hasReturnQty)||grabFlag==0"/>
  100. <span v-else>--</span>
  101. </template>
  102. <!-- 仓库仓位 -->
  103. <template slot="warehouse" slot-scope="text, record, index">
  104. <a-cascader
  105. size="small"
  106. @change="e => changeWarehouseCascade(e, record, index)"
  107. v-model="record.warehouseCascade"
  108. expand-trigger="hover"
  109. :options="warehouseCascadeData"
  110. :allowClear="false"
  111. :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
  112. placeholder="请选择仓库仓位"
  113. style="width: 100%;"
  114. v-if="(grabFlag==1)&&(record.qty!=record.hasReturnQty)||grabFlag==0"/>
  115. <span v-else>--</span>
  116. </template>
  117. <!-- 操作 -->
  118. <template slot="action" slot-scope="text, record">
  119. <span v-if="(grabFlag==1)&&(record.qty==record.hasReturnQty)">--</span>
  120. <a-button
  121. v-else
  122. size="small"
  123. type="link"
  124. class="button-primary"
  125. :loading="newLoading"
  126. @click="handleAdd(record)"
  127. >添加</a-button>
  128. </template>
  129. </s-table>
  130. </div>
  131. </template>
  132. <script>
  133. import { salesReturnProductList } from '@/api/salesReturn'
  134. import { stockList } from '@/api/stock'
  135. import { STable, VSelect } from '@/components'
  136. import rangeDate from '@/views/common/rangeDate.vue'
  137. export default {
  138. name: 'QueryPart',
  139. components: { STable, VSelect, rangeDate },
  140. props: {
  141. // buyerSn: {
  142. // type: [Number, String],
  143. // default: ''
  144. // },
  145. warehouseCascadeData: {
  146. type: Array,
  147. default: function () {
  148. return []
  149. }
  150. },
  151. newLoading: Boolean,
  152. grabFlag: [Number, String]
  153. // priceType: [Number, String]
  154. },
  155. data () {
  156. return {
  157. advanced: false, // 高级搜索 展开/关闭
  158. queryParam: { // 查询条件
  159. beginDate: '',
  160. endDate: '',
  161. salesBillNo: '', // 销售单号
  162. productName: '', // 产品名称
  163. productCode: '' // 产品编码
  164. },
  165. buyerSn: '',
  166. priceType: '',
  167. disabled: false, // 查询、重置按钮是否可操作
  168. columns: [],
  169. // 加载数据方法 必须为 Promise 对象
  170. loadData: parameter => {
  171. this.disabled = true
  172. // 抓单时
  173. if (this.grabFlag == 1) {
  174. this.queryParam.buyerSn = this.buyerSn
  175. }
  176. const fun = [stockList, salesReturnProductList]
  177. if (this.grabFlag == 0) {
  178. this.queryParam.salePriceType = this.priceType
  179. }
  180. return fun[this.grabFlag](Object.assign(parameter, this.queryParam)).then(res => {
  181. console.log(res)
  182. let data
  183. if (res.status == 200) {
  184. data = res.data
  185. const no = (data.pageNo - 1) * data.pageSize
  186. for (var i = 0; i < data.list.length; i++) {
  187. data.list[i].no = no + i + 1
  188. // 不抓单
  189. if (this.grabFlag == 0) {
  190. console.log(this.warehouseCascadeData, data)
  191. data.list[i].putCost = data.list[i].lastStockCost
  192. const warehouse = this.warehouseCascadeData.find(item => item.sysFlag == 1 && item.wasteFlag == 0)
  193. if (warehouse) {
  194. const warehouseLocation = warehouse.warehouseLocationList.find(item => item.sysFlag == 1 && item.wasteFlag == 0)
  195. if (warehouseLocation) {
  196. data.list[i].warehouseCascade = [warehouse.warehouseSn, warehouseLocation.warehouseLocationSn]
  197. }
  198. }
  199. data.list[i].returnQty = 1
  200. data.list[i].celQty = 0
  201. } else {
  202. // 抓单
  203. data.list[i].returnQty = data.list[i].qty - data.list[i].hasReturnQty
  204. data.list[i].celQty = 0
  205. const warehouseSn = data.list[i].warehouseSn || undefined
  206. const warehouseLocationSn = data.list[i].warehouseLocationSn || undefined
  207. if (warehouseSn || warehouseLocationSn) {
  208. data.list[i].warehouseCascade = [warehouseSn, warehouseLocationSn]
  209. } else {
  210. data.list[i].warehouseCascade = undefined
  211. }
  212. }
  213. }
  214. this.listData = data.list || []
  215. this.disabled = false
  216. }
  217. return data
  218. })
  219. },
  220. listData: []
  221. }
  222. },
  223. mounted () {
  224. // 抓单
  225. if (this.grabFlag == 1) {
  226. this.columns = [
  227. { title: '序号', dataIndex: 'no', align: 'center', width: '4%' },
  228. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '14%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
  229. { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  230. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  231. { title: '销售单号', dataIndex: 'salesBillNo', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  232. { title: '销售审核时间', dataIndex: 'auditDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  233. { title: '售价', dataIndex: 'price', align: 'center', width: '5%', scopedSlots: { customRender: 'price' } },
  234. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  235. { title: '销售数量', dataIndex: 'qty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  236. { title: '已退数量', dataIndex: 'hasReturnQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  237. { title: '本次退货数量', align: 'center', width: '7%', scopedSlots: { customRender: 'returnQty' } },
  238. { title: '废品数量', align: 'center', width: '6%', scopedSlots: { customRender: 'celQty' } },
  239. { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: '10%', align: 'center' },
  240. { slots: { title: 'customTitle' }, scopedSlots: { customRender: 'action' }, width: '7%', align: 'center' }]
  241. } else {
  242. this.columns = [
  243. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  244. { title: '产品编码', dataIndex: 'productCode', width: '22%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
  245. { title: '产品名称', dataIndex: 'productName', width: '22%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  246. { title: '原厂编码', dataIndex: 'productOrigCode', width: '21%', align: 'center', customRender: function (text) { return text || '--' } },
  247. { title: '售价', dataIndex: 'salePrice', width: '10%', align: 'center', scopedSlots: { customRender: 'price' } },
  248. { title: '单位', dataIndex: 'productUnit', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  249. { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: '10%', align: 'center' },
  250. { title: '本次退货数量', align: 'center', width: '7%', scopedSlots: { customRender: 'returnQty' } },
  251. { title: '废品数量', align: 'center', width: '6%', scopedSlots: { customRender: 'celQty' } },
  252. { slots: { title: 'customTitle' }, scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }]
  253. }
  254. },
  255. methods: {
  256. // 时间 change
  257. dateChange (date) {
  258. this.queryParam.beginDate = date[0]
  259. this.queryParam.endDate = date[1]
  260. },
  261. // 双击列表选择配件
  262. handleClickRow (record) {
  263. const _this = this
  264. return {
  265. on: {
  266. dblclick: (event) => {
  267. if ((_this.grabFlag == 1) && (record.qty == record.hasReturnQty)) {
  268. _this.$message.info('该产品暂时不能添加')
  269. } else {
  270. event.stopPropagation()
  271. _this.$emit('add', record, 'new')
  272. }
  273. }
  274. }
  275. }
  276. },
  277. // 修改仓库仓位
  278. changeWarehouseCascade (val, opt, ind) {
  279. console.log(val, opt, ind)
  280. const loadData = this.listData[ind]
  281. if (val.length < 2) {
  282. this.$message.warning('当前仓库无仓位,请选择其他仓库')
  283. const warehouseSnBackups = loadData.warehouseSnBackups || undefined
  284. const warehouseLocationSnBackups = loadData.warehouseLocationSnBackups || undefined
  285. loadData.warehouseSn = warehouseSnBackups
  286. loadData.warehouseLocationSn = warehouseLocationSnBackups
  287. if (warehouseSnBackups || warehouseLocationSnBackups) {
  288. loadData.warehouseCascade = [warehouseSnBackups, warehouseLocationSnBackups]
  289. } else {
  290. loadData.warehouseCascade = undefined
  291. }
  292. } else {
  293. loadData.warehouseSn = val[0] ? val[0] : ''
  294. loadData.warehouseLocationSn = val[1] ? val[1] : ''
  295. loadData.warehouseSnBackups = val[0] ? val[0] : ''
  296. loadData.warehouseLocationSnBackups = val[1] ? val[1] : ''
  297. }
  298. },
  299. // 重置
  300. resetSearchForm () {
  301. this.$refs.rangeDate && this.$refs.rangeDate.resetDate()
  302. this.queryParam.beginDate = ''
  303. this.queryParam.endDate = ''
  304. this.queryParam.salesBillNo = ''
  305. this.queryParam.productName = ''
  306. this.queryParam.productCode = ''
  307. this.$refs.table.refresh(true)
  308. },
  309. pageInit (buyerSn, priceType) {
  310. console.log(buyerSn, priceType)
  311. this.buyerSn = buyerSn
  312. this.priceType = priceType
  313. this.refreshData()
  314. },
  315. refreshData () {
  316. this.$refs.table.refresh()
  317. },
  318. // 选择配件
  319. handleAdd (row) {
  320. this.$emit('add', row, 'new')
  321. }
  322. }
  323. }
  324. </script>