list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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 @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'
  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: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  183. { title: '绑定产品编码', dataIndex: 'productCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  184. { title: '绑定产品名称', dataIndex: 'productName', width: '18%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  185. { title: '货位产品状态', dataIndex: 'stateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  186. { title: '补货在途', dataIndex: 'replenishBillQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  187. { title: '调回在途', dataIndex: 'recallBillQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  188. { title: '当前库存', dataIndex: 'qty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  189. { title: '最大库容', dataIndex: 'maxQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  190. { title: '滞销天数', dataIndex: 'unsalableDays', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  191. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'left' }
  192. ],
  193. // 加载数据方法 必须为 Promise 对象
  194. loadData: parameter => {
  195. // 校验滞销天数数值范围
  196. if (this.checkValueRange()) {
  197. this.disabled = true
  198. this.spinning = true
  199. return shelfControlList(this.queryParam).then(res => {
  200. let data
  201. if (res.status == 200) {
  202. data = res.data
  203. for (var i = 0; i < data.length; i++) {
  204. data[i].no = i + 1
  205. }
  206. this.disabled = false
  207. }
  208. this.spinning = false
  209. return data
  210. })
  211. } else {
  212. const _this = this
  213. this.disabled = true
  214. this.spinning = true
  215. return new Promise(function (resolve, reject) {
  216. const data = []
  217. _this.disabled = false
  218. _this.spinning = false
  219. resolve(data)
  220. })
  221. }
  222. },
  223. rowSelectionInfo: null,
  224. isSearch: false,
  225. openModal: false, // 新增编辑 弹框
  226. shelfName: '', // 货架名称
  227. nowData: {
  228. list: [],
  229. shelfInfo: {}
  230. }
  231. }
  232. },
  233. methods: {
  234. // 校验滞销天数数值范围
  235. checkValueRange () {
  236. const isONull = this.queryParam.unsalableDaysBegin === null || this.queryParam.unsalableDaysBegin === undefined
  237. const isOEmpty = this.queryParam.unsalableDaysBegin === ''
  238. const isOZero = this.queryParam.unsalableDaysBegin === 0
  239. const isTNull = this.queryParam.unsalableDaysEnd === null || this.queryParam.unsalableDaysEnd === undefined
  240. const isTEmpty = this.queryParam.unsalableDaysEnd === ''
  241. const isTZero = this.queryParam.unsalableDaysEnd === 0
  242. // 第一个为空(可为null可为空字符)第二个不为空
  243. // 第一个不为空第二个为空(可为null可为空字符)
  244. // 第一个大于第二个
  245. if ((isONull || isOEmpty) && (this.queryParam.unsalableDaysEnd || isTZero)) {
  246. this.$message.info('请输入正确的滞销天数查询范围!')
  247. return false
  248. }
  249. if ((this.queryParam.unsalableDaysBegin || isOZero) && (isTNull || isTEmpty)) {
  250. this.$message.info('请输入正确的滞销天数查询范围!')
  251. return false
  252. }
  253. if (this.queryParam.unsalableDaysBegin > this.queryParam.unsalableDaysEnd) {
  254. this.$message.info('请输入正确的滞销天数查询范围!')
  255. return false
  256. }
  257. this.queryParam.unsalableDaysBegin = this.queryParam.unsalableDaysBegin > 999999999 ? 999999999 : this.queryParam.unsalableDaysBegin
  258. this.queryParam.unsalableDaysEnd = this.queryParam.unsalableDaysEnd > 999999999 ? 999999999 : this.queryParam.unsalableDaysEnd
  259. return true
  260. },
  261. rowSelectionFun (obj) {
  262. this.rowSelectionInfo = obj || null
  263. },
  264. // 货架 change
  265. shelfChange (val, obj) {
  266. this.shelfName = obj && obj.shelfName || ''
  267. this.queryParam.shelfSn = val
  268. },
  269. // 查询
  270. handleSearch () {
  271. this.$refs.ruleForm.validate(valid => {
  272. if (valid) {
  273. this.$refs.table.refresh(true)
  274. this.isSearch = true
  275. } else {
  276. console.log('error submit!!')
  277. return false
  278. }
  279. })
  280. },
  281. // 重置
  282. resetSearchForm () {
  283. this.isSearch = false
  284. this.queryParam.shelfSn = undefined
  285. this.queryParam.shelfPlaceCode = ''
  286. this.queryParam.productCode = ''
  287. this.queryParam.productName = ''
  288. this.queryParam.state = undefined
  289. this.queryParam.unsalableDaysBegin = undefined
  290. this.queryParam.unsalableDaysEnd = undefined
  291. this.handleSearch()
  292. },
  293. // 新增调回单
  294. handleAddBack () {
  295. if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRows.length < 1)) {
  296. this.$message.warning('请至少选择一个产品')
  297. } else {
  298. this.nowData.list = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
  299. this.nowData.shelfInfo = {
  300. shelfName: this.shelfName,
  301. shelfSn: this.queryParam.shelfSn
  302. }
  303. this.openModal = true
  304. }
  305. },
  306. // 详情
  307. handleDetail (row) {
  308. this.$router.push({ path: `/numsGoodsShelves/shelfMonitoring/warehouseDetail/${row.shelfPlaceSn}/${row.productSn}` })
  309. },
  310. handleOk () {
  311. this.$refs.table.refresh()
  312. this.$refs.table.clearSelected() // 清空表格选中项
  313. this.isSearch = true
  314. },
  315. handleCancel () {
  316. this.openModal = false
  317. },
  318. filterOption (input, option) {
  319. return (
  320. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  321. )
  322. },
  323. pageInit () {
  324. const _this = this
  325. this.$nextTick(() => { // 页面渲染完成后的回调
  326. _this.setTableH()
  327. })
  328. },
  329. setTableH () {
  330. const tableSearchH = this.$refs.tableSearch.offsetHeight
  331. this.tableHeight = window.innerHeight - tableSearchH - 245
  332. }
  333. },
  334. watch: {
  335. advanced (newValue, oldValue) {
  336. const _this = this
  337. setTimeout(() => {
  338. _this.setTableH()
  339. }, 400)
  340. },
  341. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  342. this.setTableH()
  343. }
  344. },
  345. mounted () {
  346. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  347. this.pageInit()
  348. this.resetSearchForm()
  349. }
  350. },
  351. activated () {
  352. // 如果是新页签打开,则重置当前页面
  353. if (this.$store.state.app.isNewTab) {
  354. this.pageInit()
  355. this.resetSearchForm()
  356. }
  357. },
  358. beforeRouteEnter (to, from, next) {
  359. next(vm => {})
  360. }
  361. }
  362. </script>
  363. <style lang="less">
  364. .shelfMonitoringList-wrap{
  365. .unChoose {
  366. text-align: center;
  367. margin: 280px 0 340px;
  368. font-size: 16px;
  369. }
  370. }
  371. </style>