list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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-unsalableDaysBegin"
  56. v-model="queryParam.unsalableDaysBegin"
  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-unsalableDaysEnd"
  67. v-model="queryParam.unsalableDaysEnd"
  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="left" v-if="record.recallBillData&&record.replenishBillData">
  127. <template slot="title">
  128. <div v-if="record.recallBillData">{{ record.recallBillData.join(',') }}</div>
  129. <div v-if="record.replenishBillData">{{ record.replenishBillData.join(',') }}</div>
  130. </template>
  131. {{ record.stateDictValue }}
  132. <a-icon type="exclamation-circle" theme="filled" style="color: #39f;font-size: 16px;margin-left: 5px;vertical-align: middle;cursor: pointer;" />
  133. </a-tooltip>
  134. <span v-else>{{ record.stateDictValue }}</span>
  135. </template>
  136. <!-- 操作 -->
  137. <template slot="action" slot-scope="text, record">
  138. <a-button
  139. size="small"
  140. type="link"
  141. class="button-primary"
  142. @click="handleDetail(record)"
  143. id="shelfMonitoringList-warehousing-btn">出入库明细</a-button>
  144. </template>
  145. </s-table>
  146. </div>
  147. </a-spin>
  148. <!-- 新增调回单 -->
  149. <add-modal :openModal="openModal" :nowData="nowData" @ok="handleOk" @close="handleCancel" />
  150. </a-card>
  151. </template>
  152. <script>
  153. import { commonMixin } from '@/utils/mixin'
  154. import { STable, VSelect } from '@/components'
  155. import addModal from './addModal.vue'
  156. import shelfSList from '@/views/common/shelfList.vue'
  157. import { shelfControlList } from '@/api/shelf'
  158. export default {
  159. components: { STable, VSelect, addModal, shelfSList },
  160. mixins: [commonMixin],
  161. data () {
  162. return {
  163. spinning: false,
  164. advanced: true, // 高级搜索 展开/关闭
  165. labelCol: { span: 8 },
  166. wrapperCol: { span: 16 },
  167. tableHeight: 0,
  168. queryParam: { // 查询条件
  169. shelfSn: undefined,
  170. shelfPlaceCode: '',
  171. productCode: '',
  172. productName: '',
  173. state: undefined,
  174. unsalableDaysBegin: undefined,
  175. unsalableDaysEnd: undefined
  176. },
  177. rules: {
  178. 'shelfSn': [{ required: true, message: '请选择货架', trigger: 'change' }]
  179. },
  180. disabled: false, // 查询、重置按钮是否可操作
  181. columns: [
  182. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  183. { title: '绑定产品编码', dataIndex: 'productCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  184. { title: '绑定产品名称', dataIndex: 'productName', width: '23%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  185. { title: '货位产品状态', scopedSlots: { customRender: 'state' }, width: '15%', align: 'center' },
  186. { title: '当前库存', dataIndex: 'qty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  187. { title: '最大库容', dataIndex: 'maxQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  188. { title: '滞销天数', dataIndex: 'unsalableDays', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  189. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'left' }
  190. ],
  191. // 加载数据方法 必须为 Promise 对象
  192. loadData: parameter => {
  193. // 校验滞销天数数值范围
  194. if (this.checkValueRange()) {
  195. this.disabled = true
  196. this.spinning = true
  197. return shelfControlList(this.queryParam).then(res => {
  198. let data
  199. if (res.status == 200) {
  200. data = res.data
  201. for (var i = 0; i < data.length; i++) {
  202. data[i].no = i + 1
  203. }
  204. this.disabled = false
  205. }
  206. this.spinning = false
  207. return data
  208. })
  209. } else {
  210. const _this = this
  211. this.disabled = true
  212. this.spinning = true
  213. return new Promise(function (resolve, reject) {
  214. const data = []
  215. _this.disabled = false
  216. _this.spinning = false
  217. resolve(data)
  218. })
  219. }
  220. },
  221. rowSelectionInfo: null,
  222. isSearch: false,
  223. openModal: false, // 新增编辑 弹框
  224. shelfName: '', // 货架名称
  225. nowData: {
  226. list: [],
  227. shelfInfo: {}
  228. }
  229. }
  230. },
  231. methods: {
  232. // 校验滞销天数数值范围
  233. checkValueRange () {
  234. const isONull = this.queryParam.unsalableDaysBegin === null || this.queryParam.unsalableDaysBegin === undefined
  235. const isOEmpty = this.queryParam.unsalableDaysBegin === ''
  236. const isOZero = this.queryParam.unsalableDaysBegin === 0
  237. const isTNull = this.queryParam.unsalableDaysEnd === null || this.queryParam.unsalableDaysEnd === undefined
  238. const isTEmpty = this.queryParam.unsalableDaysEnd === ''
  239. const isTZero = this.queryParam.unsalableDaysEnd === 0
  240. // 第一个为空(可为null可为空字符)第二个不为空
  241. // 第一个不为空第二个为空(可为null可为空字符)
  242. // 第一个大于第二个
  243. if ((isONull || isOEmpty) && (this.queryParam.unsalableDaysEnd || isTZero)) {
  244. this.$message.info('请输入正确的滞销天数查询范围!')
  245. return false
  246. }
  247. if ((this.queryParam.unsalableDaysBegin || isOZero) && (isTNull || isTEmpty)) {
  248. this.$message.info('请输入正确的滞销天数查询范围!')
  249. return false
  250. }
  251. if (this.queryParam.unsalableDaysBegin > this.queryParam.unsalableDaysEnd) {
  252. this.$message.info('请输入正确的滞销天数查询范围!')
  253. return false
  254. }
  255. this.queryParam.unsalableDaysBegin = this.queryParam.unsalableDaysBegin > 999999999 ? 999999999 : this.queryParam.unsalableDaysBegin
  256. this.queryParam.unsalableDaysEnd = this.queryParam.unsalableDaysEnd > 999999999 ? 999999999 : this.queryParam.unsalableDaysEnd
  257. return true
  258. },
  259. rowSelectionFun (obj) {
  260. this.rowSelectionInfo = obj || null
  261. },
  262. // 货架 change
  263. shelfChange (obj) {
  264. this.queryParam.shelfSn = obj.key || undefined
  265. this.shelfName = obj && obj.row && obj.row.shelfName || ''
  266. },
  267. // 查询
  268. handleSearch () {
  269. this.$refs.ruleForm.validate(valid => {
  270. if (valid) {
  271. this.$refs.table.refresh(true)
  272. this.isSearch = true
  273. } else {
  274. console.log('error submit!!')
  275. return false
  276. }
  277. })
  278. },
  279. // 重置
  280. resetSearchForm () {
  281. this.isSearch = false
  282. // this.queryParam.shelfSn = undefined
  283. // this.$refs.shelfList.resetForm()
  284. this.queryParam.shelfPlaceCode = ''
  285. this.queryParam.productCode = ''
  286. this.queryParam.productName = ''
  287. this.queryParam.state = undefined
  288. this.queryParam.unsalableDaysBegin = undefined
  289. this.queryParam.unsalableDaysEnd = undefined
  290. this.handleSearch()
  291. },
  292. // 新增调回单
  293. handleAddBack () {
  294. if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRows.length < 1)) {
  295. this.$message.warning('请至少选择一个产品')
  296. } else {
  297. this.nowData.list = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
  298. this.nowData.shelfInfo = {
  299. shelfName: this.shelfName,
  300. shelfSn: this.queryParam.shelfSn
  301. }
  302. this.openModal = true
  303. }
  304. },
  305. // 详情
  306. handleDetail (row) {
  307. this.$router.push({ path: `/numsGoodsShelves/shelfMonitoring/warehouseDetail/${row.shelfPlaceSn}/${row.productSn}` })
  308. },
  309. handleOk () {
  310. this.$refs.table.refresh()
  311. this.$refs.table.clearSelected() // 清空表格选中项
  312. this.isSearch = true
  313. },
  314. handleCancel () {
  315. this.openModal = false
  316. },
  317. filterOption (input, option) {
  318. return (
  319. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  320. )
  321. },
  322. pageInit () {
  323. const _this = this
  324. this.$nextTick(() => { // 页面渲染完成后的回调
  325. _this.setTableH()
  326. })
  327. },
  328. setTableH () {
  329. const tableSearchH = this.$refs.tableSearch.offsetHeight
  330. this.tableHeight = window.innerHeight - tableSearchH - 245
  331. }
  332. },
  333. watch: {
  334. advanced (newValue, oldValue) {
  335. const _this = this
  336. setTimeout(() => {
  337. _this.setTableH()
  338. }, 400)
  339. },
  340. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  341. this.setTableH()
  342. }
  343. },
  344. mounted () {
  345. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  346. this.pageInit()
  347. this.resetSearchForm()
  348. }
  349. },
  350. activated () {
  351. // 如果是新页签打开,则重置当前页面
  352. if (this.$store.state.app.isNewTab) {
  353. this.pageInit()
  354. this.resetSearchForm()
  355. }
  356. },
  357. beforeRouteEnter (to, from, next) {
  358. next(vm => {})
  359. }
  360. }
  361. </script>
  362. <style lang="less">
  363. .shelfMonitoringList-wrap{
  364. .unChoose {
  365. text-align: center;
  366. margin: 280px 0 340px;
  367. font-size: 16px;
  368. }
  369. }
  370. </style>