queryPart.vue 13 KB

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