list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <a-card size="small" :bordered="false" class="warehouseAllocationList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" ref="searchForm" :model="queryParam" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="创建时间">
  10. <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="调出仓库">
  15. <a-select id="warehouseAllocation-basicInfo-outWarehouseSn" allowClear placeholder="请选择调出仓库" v-model="queryParam.outWarehouseSn">
  16. <a-select-option v-for="(item, index) in warehouseList" :key="index" :value="item.warehouseSn">{{ item.name }}</a-select-option>
  17. </a-select>
  18. </a-form-item>
  19. </a-col>
  20. <a-col :md="6" :sm="24">
  21. <a-form-item label="调入仓库">
  22. <a-select id="warehouseAllocation-basicInfo-putWarehouseSn" allowClear placeholder="请选择调入仓库" v-model="queryParam.putWarehouseSn">
  23. <a-select-option v-for="(item, index) in warehouseList" :key="index" :value="item.warehouseSn">{{ item.name }}</a-select-option>
  24. </a-select>
  25. </a-form-item>
  26. </a-col>
  27. <template v-if="advanced">
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="业务状态">
  30. <v-select
  31. v-model="queryParam.state"
  32. ref="state"
  33. id="warehouseAllocationList-state"
  34. code="ALLOCATION_WAREHOUSE_STATE"
  35. placeholder="请选择业务状态"
  36. allowClear
  37. ></v-select>
  38. </a-form-item>
  39. </a-col>
  40. </template>
  41. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  42. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="warehouseAllocationList-refresh">查询</a-button>
  43. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="warehouseAllocationList-reset">重置</a-button>
  44. <a @click="advanced = !advanced" style="margin-left: 8px">
  45. {{ advanced ? '收起' : '展开' }}
  46. <a-icon :type="advanced ? 'up' : 'down'" />
  47. </a>
  48. </a-col>
  49. </a-row>
  50. </a-form>
  51. </div>
  52. <!-- 操作按钮 -->
  53. <div class="table-operator"><a-button id="warehouseAllocationList-add" v-if="$hasPermissions('B_warehouseAllocationNews')" type="primary" class="button-error" @click="openModal = true">新增</a-button></div>
  54. <!-- 列表 -->
  55. <s-table
  56. class="sTable fixPagination"
  57. ref="table"
  58. :style="{ height: tableHeight+84.5+'px' }"
  59. size="small"
  60. :rowKey="record => record.id"
  61. :columns="columns"
  62. :data="loadData"
  63. :scroll="{ y: tableHeight }"
  64. :defaultLoadData="false"
  65. bordered>
  66. <!-- 单号 -->
  67. <template slot="allocationWarehouseNo" slot-scope="text, record">
  68. <span style="color: #ed1c24;cursor: pointer;" v-if="$hasPermissions('B_warehouseAllocationDetail')" @click="handleDetail(record)">{{ record.allocationWarehouseNo }}</span>
  69. <span v-else>{{ record.allocationWarehouseNo }}</span>
  70. </template>
  71. <!-- 操作 -->
  72. <template slot="action" slot-scope="text, record">
  73. <a-button
  74. v-if="record.state == 'WAIT_AUDIT'&&$hasPermissions('B_allocWarehouseAudit')"
  75. size="small"
  76. type="link"
  77. class="button-warning"
  78. @click="handleExamine(record)"
  79. id="warehouseAllocationList-examine-btn">
  80. 审核
  81. </a-button>
  82. <a-button
  83. v-if="((record.state == 'WAIT_SUBMIT') || (record.state == 'WAIT_AUDIT')) && $hasPermissions('B_warehouseAllocationEdit')"
  84. size="small"
  85. type="link"
  86. class="button-info"
  87. @click="handleEdit(record)"
  88. id="warehouseAllocationList-edit-btn">
  89. 编辑
  90. </a-button>
  91. <a-button
  92. v-if="((record.state == 'WAIT_SUBMIT') || (record.state == 'WAIT_AUDIT')) && $hasPermissions('B_warehouseAllocationDel')"
  93. size="small"
  94. type="link"
  95. class="button-error"
  96. @click="handleDel(record)"
  97. id="warehouseAllocationList-del-btn">
  98. 删除
  99. </a-button>
  100. <span v-if="((record.state != 'WAIT_SUBMIT') && (record.state != 'WAIT_AUDIT')) || (!(record.state == 'WAIT_AUDIT'&&$hasPermissions('B_allocWarehouseAudit')) && !(((record.state == 'WAIT_SUBMIT') || (record.state == 'WAIT_AUDIT')) && $hasPermissions('B_warehouseAllocationEdit')) &&!(((record.state == 'WAIT_SUBMIT') || (record.state == 'WAIT_AUDIT')) && $hasPermissions('B_warehouseAllocationDel'))) ">--</span>
  101. </template>
  102. </s-table>
  103. </a-spin>
  104. <!-- 新增/编辑 -->
  105. <basic-info-modal :openModal="openModal" @ok="handleEdit" @close="openModal=false" />
  106. </a-card>
  107. </template>
  108. <script>
  109. import { allocWarehouseList, allocWarehouseAudit, allocWarehouseDel } from '@/api/allocWarehouse'
  110. import { warehouseAllList } from '@/api/warehouse.js'
  111. import { STable, VSelect } from '@/components'
  112. import basicInfoModal from './basicInfoModal.vue'
  113. import rangeDate from '@/views/common/rangeDate.vue'
  114. import getDate from '@/libs/getDate.js'
  115. export default {
  116. components: { STable, VSelect, basicInfoModal, rangeDate },
  117. data () {
  118. return {
  119. spinning: false,
  120. advanced: true, // 高级搜索 展开/关闭
  121. tableHeight: 0,
  122. warehouseList: [], // 仓库列表
  123. time: [
  124. getDate.getCurrMonthDays().starttime,
  125. getDate.getCurrMonthDays().endtime
  126. ],
  127. queryParam: { // 查询条件
  128. beginDate: getDate.getCurrMonthDays().starttime,
  129. endDate: getDate.getCurrMonthDays().endtime,
  130. outWarehouseSn: undefined, // 调出仓库
  131. putWarehouseSn: undefined, // 调入仓库
  132. state: undefined // 审核状态
  133. },
  134. disabled: false, // 查询、重置按钮是否可操作
  135. columns: [
  136. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  137. { title: '创建时间', dataIndex: 'createDate', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  138. { title: '单号', scopedSlots: { customRender: 'allocationWarehouseNo' }, width: '15%', align: 'center' },
  139. { title: '调出仓库', dataIndex: 'outWarehouseName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  140. { title: '调入仓库', dataIndex: 'putWarehouseName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  141. { title: '总款数', dataIndex: 'productTotalCategory', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  142. { title: '总数量', dataIndex: 'productTotalQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  143. { title: '总成本', dataIndex: 'productTotalCost', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  144. { title: '审核时间', dataIndex: 'auditTime', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  145. { title: '业务状态', dataIndex: 'stateDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  146. { title: '操作', scopedSlots: { customRender: 'action' }, width: '12%', align: 'center' }
  147. ],
  148. // 加载数据方法 必须为 Promise 对象
  149. loadData: parameter => {
  150. this.disabled = true
  151. this.spinning = true
  152. return allocWarehouseList(Object.assign(parameter, this.queryParam)).then(res => {
  153. const data = res.data
  154. const no = (data.pageNo - 1) * data.pageSize
  155. for (var i = 0; i < data.list.length; i++) {
  156. data.list[i].no = no + i + 1
  157. }
  158. this.disabled = false
  159. this.spinning = false
  160. return data
  161. })
  162. },
  163. openModal: false // 新增编辑 弹框
  164. }
  165. },
  166. methods: {
  167. // 时间 change
  168. dateChange (date) {
  169. this.queryParam.beginDate = date[0]
  170. this.queryParam.endDate = date[1]
  171. },
  172. // 获取仓库列表
  173. getWarehouseList () {
  174. warehouseAllList({}).then(res => {
  175. if (res.status == 200) {
  176. this.warehouseList = res.data || []
  177. } else {
  178. this.warehouseList = []
  179. }
  180. })
  181. },
  182. // 重置
  183. resetSearchForm () {
  184. this.$refs.rangeDate.resetDate(this.time)
  185. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  186. this.queryParam.endDate = getDate.getCurrMonthDays().endtime,
  187. this.queryParam.outWarehouseSn = undefined
  188. this.queryParam.putWarehouseSn = undefined
  189. this.queryParam.state = undefined
  190. this.$refs.table.refresh(true)
  191. },
  192. // 删除
  193. handleDel (row) {
  194. const _this = this
  195. this.$confirm({
  196. title: '提示',
  197. content: '删除后不可恢复,确定要进行删除吗?',
  198. centered: true,
  199. onOk () {
  200. _this.spinning = true
  201. allocWarehouseDel({ id: row.id }).then(res => {
  202. if (res.status == 200) {
  203. _this.$message.success(res.message)
  204. _this.$refs.table.refresh()
  205. _this.spinning = false
  206. } else {
  207. _this.spinning = false
  208. }
  209. })
  210. }
  211. })
  212. },
  213. // 审核
  214. handleExamine (row) {
  215. const _this = this
  216. this.$confirm({
  217. title: '提示',
  218. content: '确认要审核通过吗?',
  219. centered: true,
  220. onOk () {
  221. _this.spinning = true
  222. allocWarehouseAudit({ allocationWarehouseSn: row.allocationWarehouseSn }).then(res => {
  223. if (res.status == 200) {
  224. _this.$message.success(res.message)
  225. _this.$refs.table.refresh()
  226. _this.spinning = false
  227. } else {
  228. _this.spinning = false
  229. }
  230. })
  231. }
  232. })
  233. },
  234. // 详情
  235. handleDetail (row) {
  236. this.$router.push({ path: `/allocationManagement/warehouseAllocation/detail/${row.allocationWarehouseSn}` })
  237. },
  238. // 新增/编辑
  239. handleEdit (row) {
  240. this.$router.push({ path: `/allocationManagement/warehouseAllocation/edit/${row.id}/${row.allocationWarehouseSn}` })
  241. },
  242. pageInit () {
  243. const _this = this
  244. this.$nextTick(() => { // 页面渲染完成后的回调
  245. _this.setTableH()
  246. })
  247. this.getWarehouseList()
  248. },
  249. setTableH () {
  250. const tableSearchH = this.$refs.tableSearch.offsetHeight
  251. this.tableHeight = window.innerHeight - tableSearchH - 235
  252. }
  253. },
  254. watch: {
  255. advanced (newValue, oldValue) {
  256. const _this = this
  257. setTimeout(() => {
  258. _this.setTableH()
  259. }, 400)
  260. },
  261. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  262. this.setTableH()
  263. }
  264. },
  265. mounted () {
  266. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  267. this.pageInit()
  268. this.resetSearchForm()
  269. }
  270. },
  271. activated () {
  272. // 如果是新页签打开,则重置当前页面
  273. if (this.$store.state.app.isNewTab) {
  274. this.pageInit()
  275. this.resetSearchForm()
  276. }
  277. // 仅刷新列表,不重置页面
  278. if (this.$store.state.app.updateList) {
  279. this.pageInit()
  280. this.$refs.table.refresh()
  281. }
  282. },
  283. beforeRouteEnter (to, from, next) {
  284. next(vm => {})
  285. }
  286. }
  287. </script>