list.vue 16 KB

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