list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <a-card size="small" :bordered="false" class="shelfMonitoringList-wrap jg-page-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 id="shelfMonitoringList-shelfSn" 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. <a-col :md="6" :sm="24">
  33. <a-form-model-item label="货位产品状态">
  34. <v-select
  35. v-model="queryParam.state"
  36. ref="state"
  37. id="shelfMonitoringList-state"
  38. code="SHELF_PRODUCT_STATE"
  39. placeholder="请选择货位产品状态"
  40. allowClear></v-select>
  41. </a-form-model-item>
  42. </a-col>
  43. <template v-if="advanced">
  44. <a-col :md="6" :sm="24">
  45. <a-form-model-item label="产品名称">
  46. <a-input id="shelfMonitoringList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  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" id="shelfMonitoringList-advanced">
  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" 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-add" @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" 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'+record.id">出入库明细</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, // 货架sn
  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. if ((isONull || isOEmpty) && (this.queryParam.unsalableDaysEnd || isTZero)) {
  253. this.$message.info('请输入正确的滞销天数查询范围!')
  254. return false
  255. }
  256. // 第一个不为空第二个为空(可为null可为空字符)
  257. if ((this.queryParam.unsalableDaysBegin || isOZero) && (isTNull || isTEmpty)) {
  258. this.$message.info('请输入正确的滞销天数查询范围!')
  259. return false
  260. }
  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. // 全选、勾选表格
  271. rowSelectionFun (obj) {
  272. this.rowSelectionInfo = obj || null
  273. },
  274. // 选择货架 change
  275. shelfChange (val, obj) {
  276. this.shelfName = obj && obj.shelfName || ''
  277. this.queryParam.shelfSn = val
  278. },
  279. // 查询列表
  280. handleSearch () {
  281. this.$refs.ruleForm.validate(valid => {
  282. if (valid) {
  283. this.$refs.table.clearSelected()
  284. this.$refs.table.refresh(true)
  285. this.isSearch = true
  286. } else {
  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. // 新增调回单成功后
  340. handleOk () {
  341. this.$refs.table.refresh()
  342. this.$refs.table.clearSelected() // 清空表格选中项
  343. this.isSearch = true
  344. },
  345. // 关闭新增回调单弹框
  346. handleCancel () {
  347. this.openModal = false
  348. },
  349. // 页面初始化
  350. pageInit () {
  351. const _this = this
  352. this.$nextTick(() => { // 页面渲染完成后的回调
  353. _this.setTableH()
  354. })
  355. },
  356. // 设置表格高度
  357. setTableH () {
  358. const tableSearchH = this.$refs.tableSearch.offsetHeight
  359. this.tableHeight = window.innerHeight - tableSearchH - 245
  360. }
  361. },
  362. watch: {
  363. advanced (newValue, oldValue) {
  364. const _this = this
  365. setTimeout(() => {
  366. _this.setTableH()
  367. }, 400)
  368. },
  369. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  370. this.setTableH()
  371. }
  372. },
  373. mounted () {
  374. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  375. this.pageInit()
  376. this.resetSearchForm()
  377. }
  378. },
  379. activated () {
  380. // 如果是新页签打开,则重置当前页面
  381. if (this.$store.state.app.isNewTab) {
  382. this.pageInit()
  383. this.resetSearchForm()
  384. }
  385. },
  386. beforeRouteEnter (to, from, next) {
  387. next(vm => {})
  388. }
  389. }
  390. </script>
  391. <style lang="less">
  392. .shelfMonitoringList-wrap{
  393. .unChoose {
  394. text-align: center;
  395. margin: 280px 0 340px;
  396. font-size: 16px;
  397. }
  398. }
  399. </style>