list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <a-card size="small" :bordered="false" class="shelfMonitoringList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form-model
  7. id="shelfMonitoringList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="queryParam"
  12. :rules="rules"
  13. :labelCol="labelCol"
  14. :wrapperCol="wrapperCol"
  15. @keyup.enter.native="handleSearch" >
  16. <a-row :gutter="15">
  17. <a-col :md="6" :sm="24">
  18. <a-form-model-item label="货架名称" prop="shelfSn">
  19. <shelfSList ref="shelfList" @change="shelfChange" :itemSn="queryParam.shelfSn"></shelfSList>
  20. </a-form-model-item>
  21. </a-col>
  22. <a-col :md="6" :sm="24">
  23. <a-form-model-item label="货位号">
  24. <a-input id="shelfMonitoringList-shelfPlaceCode" v-model.trim="queryParam.shelfPlaceCode" allowClear placeholder="请输入货位号"/>
  25. </a-form-model-item>
  26. </a-col>
  27. <a-col :md="6" :sm="24">
  28. <a-form-model-item label="产品编码">
  29. <a-input id="shelfMonitoringList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  30. </a-form-model-item>
  31. </a-col>
  32. <template v-if="advanced">
  33. <a-col :md="6" :sm="24">
  34. <a-form-model-item label="产品名称">
  35. <a-input id="shelfMonitoringList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  36. </a-form-model-item>
  37. </a-col>
  38. <a-col :md="6" :sm="24">
  39. <a-form-model-item label="货位产品状态">
  40. <v-select
  41. v-model="queryParam.state"
  42. ref="state"
  43. id="shelfMonitoringList-state"
  44. code="SHELF_PRODUCT_STATE"
  45. placeholder="请选择货位产品状态"
  46. allowClear></v-select>
  47. </a-form-model-item>
  48. </a-col>
  49. <a-col :md="6" :sm="24">
  50. <a-form-model-item label="滞销天数">
  51. <a-input-group>
  52. <a-row>
  53. <a-col :span="11">
  54. <a-input-number
  55. id="shelfMonitoringList-beginDate"
  56. v-model="queryParam.beginDate"
  57. :precision="0"
  58. :min="0"
  59. :max="999999"
  60. placeholder="起始天数"
  61. style="width: 100%;display: inline-block;" />
  62. </a-col>
  63. <a-col :span="2"><span style="display: block;text-align: center;line-height: 32px;">至</span></a-col>
  64. <a-col :span="11">
  65. <a-input-number
  66. id="shelfMonitoringList-endDate"
  67. v-model="queryParam.endDate"
  68. :precision="0"
  69. :min="0"
  70. :max="999999"
  71. placeholder="截止天数"
  72. style="width: 100%;display: inline-block;" />
  73. </a-col>
  74. </a-row>
  75. </a-input-group>
  76. </a-form-model-item>
  77. </a-col>
  78. </template>
  79. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  80. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="shelfMonitoringList-refresh">查询</a-button>
  81. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="shelfMonitoringList-reset">重置</a-button>
  82. <a @click="advanced=!advanced" style="margin-left: 5px">
  83. {{ advanced ? '收起' : '展开' }}
  84. <a-icon :type="advanced ? 'up' : 'down'"/>
  85. </a>
  86. </a-col>
  87. </a-row>
  88. </a-form-model>
  89. </div>
  90. <!-- 未选择合作商 -->
  91. <div class="unChoose" v-show="!isSearch">
  92. <a-icon type="exclamation-circle" theme="filled" :style="{ fontSize: '18px', color: '#ff9900', verticalAlign: 'sub', marginRight: '5px' }" />
  93. <span>请选择一个货架后点击查询按钮</span>
  94. </div>
  95. <div v-show="isSearch">
  96. <div style="margin-bottom: 10px">
  97. <div style="display: inline-block;margin-right: 15px;vertical-align: middle;font-weight: bold;font-size: 14px;">
  98. <a-divider type="vertical" style="background: #FF7D0C;width: 3px;height: 16px;" />
  99. <span>{{ shelfName || '--' }}</span>
  100. </div>
  101. <!-- <a-button type="primary" class="button-error" id="shelfMonitoringList-export" @click="handleAddBack">新增调回单</a-button> -->
  102. <span style="margin-left: 5px">
  103. <template v-if="rowSelectionInfo&&rowSelectionInfo.selectedRowKeys.length > 0">
  104. {{ `已选 ${rowSelectionInfo.selectedRowKeys.length} 项` }}
  105. </template>
  106. </span>
  107. </div>
  108. <!-- 列表 -->
  109. <s-table
  110. class="sTable fixPagination"
  111. ref="table"
  112. :style="{ height: tableHeight+84.5+'px' }"
  113. size="small"
  114. :rowKey="(record) => record.shelfPlaceSn"
  115. :columns="columns"
  116. :data="loadData"
  117. rowKeyName="shelfPlaceSn"
  118. :row-selection="{ columnWidth: 40 }"
  119. @rowSelection="rowSelectionFun"
  120. :scroll="{ y: tableHeight }"
  121. :defaultLoadData="false"
  122. :showPagination="false"
  123. bordered>
  124. <!-- 绑定产品状态 -->
  125. <template slot="state" slot-scope="text, record">
  126. <a-tooltip placement="top">
  127. <template slot="title">
  128. <span>{{ record.productTypeName }}</span>
  129. </template>
  130. {{ record.stateDictValue }}
  131. <a-icon type="exclamation-circle" theme="filled" style="color: #39f;font-size: 16px;margin-left: 5px;vertical-align: middle;cursor: pointer;" />
  132. </a-tooltip>
  133. </template>
  134. <!-- 操作 -->
  135. <template slot="action" slot-scope="text, record">
  136. <a-button
  137. size="small"
  138. type="link"
  139. class="button-primary"
  140. @click="handleDetail(record)"
  141. id="shelfMonitoringList-warehousing-btn">出入库明细</a-button>
  142. </template>
  143. </s-table>
  144. </div>
  145. </a-spin>
  146. <!-- 新增调回单 -->
  147. <add-modal :openModal="openModal" :nowData="nowData" @ok="handleOk" @close="handleCancel" />
  148. </a-card>
  149. </template>
  150. <script>
  151. import { commonMixin } from '@/utils/mixin'
  152. import { STable, VSelect } from '@/components'
  153. import addModal from './addModal.vue'
  154. import shelfSList from '@/views/common/shelfList.vue'
  155. import { shelfControlList } from '@/api/shelf'
  156. export default {
  157. components: { STable, VSelect, addModal, shelfSList },
  158. mixins: [commonMixin],
  159. data () {
  160. return {
  161. spinning: false,
  162. advanced: true, // 高级搜索 展开/关闭
  163. labelCol: { span: 8 },
  164. wrapperCol: { span: 16 },
  165. tableHeight: 0,
  166. queryParam: { // 查询条件
  167. shelfSn: undefined,
  168. shelfPlaceCode: '',
  169. productCode: '',
  170. productName: '',
  171. state: undefined,
  172. beginDate: undefined,
  173. endDate: undefined
  174. },
  175. rules: {
  176. 'shelfSn': [{ required: true, message: '请选择货架', trigger: 'change' }]
  177. },
  178. disabled: false, // 查询、重置按钮是否可操作
  179. columns: [
  180. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  181. { title: '绑定产品编码', dataIndex: 'productCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  182. { title: '绑定产品名称', dataIndex: 'productName', width: '23%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  183. { title: '货位产品状态', scopedSlots: { customRender: 'state' }, width: '15%', align: 'center' },
  184. { title: '当前库存', dataIndex: 'qty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  185. { title: '最大库容', dataIndex: 'maxQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  186. { title: '滞销天数', dataIndex: 'unsalableDays', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  187. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'left' }
  188. ],
  189. // 加载数据方法 必须为 Promise 对象
  190. loadData: parameter => {
  191. // 校验滞销天数数值范围
  192. if (this.checkValueRange()) {
  193. this.disabled = true
  194. this.spinning = true
  195. return shelfControlList(this.queryParam).then(res => {
  196. let data
  197. if (res.status == 200) {
  198. data = res.data
  199. for (var i = 0; i < data.length; i++) {
  200. data[i].no = i + 1
  201. }
  202. this.disabled = false
  203. }
  204. this.spinning = false
  205. return data
  206. })
  207. } else {
  208. const _this = this
  209. this.disabled = true
  210. this.spinning = true
  211. return new Promise(function (resolve, reject) {
  212. const data = []
  213. _this.disabled = false
  214. _this.spinning = false
  215. resolve(data)
  216. })
  217. }
  218. },
  219. rowSelectionInfo: null,
  220. isSearch: false,
  221. openModal: false, // 新增编辑 弹框
  222. shelfName: '', // 货架名称
  223. nowData: {
  224. list: [],
  225. shelfInfo: {}
  226. }
  227. }
  228. },
  229. methods: {
  230. // 校验滞销天数数值范围
  231. checkValueRange () {
  232. const isONull = this.queryParam.beginDate === null || this.queryParam.beginDate === undefined
  233. const isOEmpty = this.queryParam.beginDate === ''
  234. const isOZero = this.queryParam.beginDate === 0
  235. const isTNull = this.queryParam.endDate === null || this.queryParam.endDate === undefined
  236. const isTEmpty = this.queryParam.endDate === ''
  237. const isTZero = this.queryParam.endDate === 0
  238. // 第一个为空(可为null可为空字符)第二个不为空
  239. // 第一个不为空第二个为空(可为null可为空字符)
  240. // 第一个大于第二个
  241. if ((isONull || isOEmpty) && (this.queryParam.endDate || isTZero)) {
  242. this.$message.info('请输入正确的滞销天数查询范围!')
  243. return false
  244. }
  245. if ((this.queryParam.beginDate || isOZero) && (isTNull || isTEmpty)) {
  246. this.$message.info('请输入正确的滞销天数查询范围!')
  247. return false
  248. }
  249. if (this.queryParam.beginDate > this.queryParam.endDate) {
  250. this.$message.info('请输入正确的滞销天数查询范围!')
  251. return false
  252. }
  253. this.queryParam.beginDate = this.queryParam.beginDate > 999999999 ? 999999999 : this.queryParam.beginDate
  254. this.queryParam.endDate = this.queryParam.endDate > 999999999 ? 999999999 : this.queryParam.endDate
  255. return true
  256. },
  257. rowSelectionFun (obj) {
  258. this.rowSelectionInfo = obj || null
  259. },
  260. // 货架 change
  261. shelfChange (obj) {
  262. this.queryParam.shelfSn = obj.key || undefined
  263. this.shelfName = obj && obj.row && obj.row.shelfName || ''
  264. },
  265. // 查询
  266. handleSearch () {
  267. this.$refs.ruleForm.validate(valid => {
  268. if (valid) {
  269. this.$refs.table.refresh(true)
  270. this.isSearch = true
  271. } else {
  272. console.log('error submit!!')
  273. return false
  274. }
  275. })
  276. },
  277. // 重置
  278. resetSearchForm () {
  279. this.isSearch = false
  280. this.queryParam.shelfSn = undefined
  281. this.$refs.shelfList.resetForm()
  282. this.queryParam.shelfPlaceCode = ''
  283. this.queryParam.productCode = ''
  284. this.queryParam.productName = ''
  285. this.queryParam.state = undefined
  286. this.queryParam.beginDate = undefined
  287. this.queryParam.endDate = undefined
  288. this.$refs.ruleForm.resetFields()
  289. this.$refs.table.clearTable()
  290. },
  291. // 新增调回单
  292. handleAddBack () {
  293. if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRows.length < 1)) {
  294. this.$message.warning('请至少选择一个产品')
  295. } else {
  296. this.nowData.list = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
  297. this.nowData.shelfInfo = {
  298. shelfName: this.shelfName,
  299. shelfSn: this.queryParam.shelfSn
  300. }
  301. this.openModal = true
  302. }
  303. },
  304. // 详情
  305. handleDetail (row) {
  306. this.$router.push({ path: `/numsGoodsShelves/shelfMonitoring/warehouseDetail/${row.shelfPlaceSn}/${row.productSn}` })
  307. },
  308. handleOk () {
  309. this.$refs.table.refresh()
  310. this.$refs.table.clearSelected() // 清空表格选中项
  311. this.isSearch = true
  312. },
  313. handleCancel () {
  314. this.openModal = false
  315. },
  316. filterOption (input, option) {
  317. return (
  318. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  319. )
  320. },
  321. pageInit () {
  322. const _this = this
  323. this.$nextTick(() => { // 页面渲染完成后的回调
  324. _this.setTableH()
  325. })
  326. },
  327. setTableH () {
  328. const tableSearchH = this.$refs.tableSearch.offsetHeight
  329. this.tableHeight = window.innerHeight - tableSearchH - 245
  330. }
  331. },
  332. watch: {
  333. advanced (newValue, oldValue) {
  334. const _this = this
  335. setTimeout(() => {
  336. _this.setTableH()
  337. }, 400)
  338. },
  339. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  340. this.setTableH()
  341. }
  342. },
  343. mounted () {
  344. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  345. this.pageInit()
  346. this.resetSearchForm()
  347. }
  348. },
  349. activated () {
  350. // 如果是新页签打开,则重置当前页面
  351. if (this.$store.state.app.isNewTab) {
  352. this.pageInit()
  353. this.resetSearchForm()
  354. }
  355. },
  356. beforeRouteEnter (to, from, next) {
  357. next(vm => {})
  358. }
  359. }
  360. </script>
  361. <style lang="less">
  362. .shelfMonitoringList-wrap{
  363. .unChoose {
  364. text-align: center;
  365. margin: 280px 0 340px;
  366. font-size: 16px;
  367. }
  368. }
  369. </style>