queryPart.vue 13 KB

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