list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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" @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="{ x: 1260, y: tableHeight }"
  64. bordered>
  65. <!-- 单号 -->
  66. <template slot="allocationWarehouseNo" slot-scope="text, record">
  67. <span style="color: #ed1c24;cursor: pointer;" v-if="$hasPermissions('B_warehouseAllocationDetail')" @click="handleDetail(record)">{{ record.allocationWarehouseNo }}</span>
  68. <span v-else>{{ record.allocationWarehouseNo }}</span>
  69. </template>
  70. <!-- 操作 -->
  71. <template slot="action" slot-scope="text, record">
  72. <a-button
  73. v-if="record.state == 'WAIT_AUDIT'&&$hasPermissions('B_allocWarehouseAudit')"
  74. size="small"
  75. type="link"
  76. class="button-warning"
  77. @click="handleExamine(record)"
  78. id="warehouseAllocationList-examine-btn">
  79. 审核
  80. </a-button>
  81. <a-button
  82. v-if="((record.state == 'WAIT_SUBMIT') || (record.state == 'WAIT_AUDIT')) && $hasPermissions('B_warehouseAllocationEdit')"
  83. size="small"
  84. type="link"
  85. class="button-info"
  86. @click="handleEdit(record)"
  87. id="warehouseAllocationList-edit-btn">
  88. 编辑
  89. </a-button>
  90. <a-button
  91. v-if="((record.state == 'WAIT_SUBMIT') || (record.state == 'WAIT_AUDIT')) && $hasPermissions('B_warehouseAllocationDel')"
  92. size="small"
  93. type="link"
  94. class="button-error"
  95. @click="handleDel(record)"
  96. id="warehouseAllocationList-del-btn">
  97. 删除
  98. </a-button>
  99. <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>
  100. </template>
  101. </s-table>
  102. </a-spin>
  103. <!-- 新增/编辑 -->
  104. <basic-info-modal :openModal="openModal" @ok="handleEdit" @close="openModal=false" />
  105. </a-card>
  106. </template>
  107. <script>
  108. import { allocWarehouseList, allocWarehouseAudit, allocWarehouseDel } from '@/api/allocWarehouse'
  109. import { warehouseAllList } from '@/api/warehouse.js'
  110. import { STable, VSelect } from '@/components'
  111. import basicInfoModal from './basicInfoModal.vue'
  112. import rangeDate from '@/views/common/rangeDate.vue'
  113. export default {
  114. components: { STable, VSelect, basicInfoModal, rangeDate },
  115. data () {
  116. return {
  117. spinning: false,
  118. advanced: true, // 高级搜索 展开/关闭
  119. tableHeight: 0,
  120. warehouseList: [], // 仓库列表
  121. queryParam: { // 查询条件
  122. beginDate: '',
  123. endDate: '',
  124. outWarehouseSn: undefined, // 调出仓库
  125. putWarehouseSn: undefined, // 调入仓库
  126. state: undefined // 审核状态
  127. },
  128. disabled: false, // 查询、重置按钮是否可操作
  129. columns: [
  130. { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
  131. { title: '创建时间', dataIndex: 'createDate', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  132. { title: '单号', scopedSlots: { customRender: 'allocationWarehouseNo' }, width: 140, align: 'center' },
  133. { title: '调出仓库', dataIndex: 'outWarehouseName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  134. { title: '调入仓库', dataIndex: 'putWarehouseName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  135. { title: '总款数', dataIndex: 'productTotalCategory', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  136. { title: '总数量', dataIndex: 'productTotalQty', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  137. { title: '总成本', dataIndex: 'productTotalCost', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  138. { title: '审核时间', dataIndex: 'auditTime', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  139. { title: '业务状态', dataIndex: 'stateDictValue', width: 80, align: 'center', customRender: function (text) { return text || '--' } },
  140. { title: '操作', scopedSlots: { customRender: 'action' }, width: 150, align: 'center', fixed: 'right' }
  141. ],
  142. // 加载数据方法 必须为 Promise 对象
  143. loadData: parameter => {
  144. this.disabled = true
  145. this.spinning = true
  146. return allocWarehouseList(Object.assign(parameter, this.queryParam)).then(res => {
  147. const data = res.data
  148. const no = (data.pageNo - 1) * data.pageSize
  149. for (var i = 0; i < data.list.length; i++) {
  150. data.list[i].no = no + i + 1
  151. }
  152. this.disabled = false
  153. this.spinning = false
  154. return data
  155. })
  156. },
  157. openModal: false // 新增编辑 弹框
  158. }
  159. },
  160. methods: {
  161. // 时间 change
  162. dateChange (date) {
  163. this.queryParam.beginDate = date[0]
  164. this.queryParam.endDate = date[1]
  165. },
  166. // 获取仓库列表
  167. getWarehouseList () {
  168. warehouseAllList({}).then(res => {
  169. if (res.status == 200) {
  170. this.warehouseList = res.data || []
  171. } else {
  172. this.warehouseList = []
  173. }
  174. })
  175. },
  176. // 重置
  177. resetSearchForm () {
  178. this.$refs.rangeDate.resetDate()
  179. this.queryParam.beginDate = ''
  180. this.queryParam.endDate = ''
  181. this.queryParam.outWarehouseSn = undefined
  182. this.queryParam.putWarehouseSn = undefined
  183. this.queryParam.state = undefined
  184. this.$refs.table.refresh(true)
  185. },
  186. // 删除
  187. handleDel (row) {
  188. const _this = this
  189. this.$confirm({
  190. title: '提示',
  191. content: '删除后不可恢复,确定要进行删除吗?',
  192. centered: true,
  193. onOk () {
  194. _this.spinning = true
  195. allocWarehouseDel({ id: row.id }).then(res => {
  196. if (res.status == 200) {
  197. _this.$message.success(res.message)
  198. _this.$refs.table.refresh()
  199. _this.spinning = false
  200. } else {
  201. _this.spinning = false
  202. }
  203. })
  204. }
  205. })
  206. },
  207. // 审核
  208. handleExamine (row) {
  209. const _this = this
  210. this.$confirm({
  211. title: '提示',
  212. content: '确认要审核通过吗?',
  213. centered: true,
  214. onOk () {
  215. _this.spinning = true
  216. allocWarehouseAudit({ allocationWarehouseSn: row.allocationWarehouseSn }).then(res => {
  217. if (res.status == 200) {
  218. _this.$message.success(res.message)
  219. _this.$refs.table.refresh()
  220. _this.spinning = false
  221. } else {
  222. _this.spinning = false
  223. }
  224. })
  225. }
  226. })
  227. },
  228. // 详情
  229. handleDetail (row) {
  230. this.$router.push({ path: `/allocationManagement/warehouseAllocation/detail/${row.allocationWarehouseSn}` })
  231. },
  232. // 新增/编辑
  233. handleEdit (row) {
  234. this.$router.push({ path: `/allocationManagement/warehouseAllocation/edit/${row.id}/${row.allocationWarehouseSn}` })
  235. },
  236. setTableH () {
  237. const tableSearchH = this.$refs.tableSearch.offsetHeight
  238. this.tableHeight = window.innerHeight - tableSearchH - 235
  239. }
  240. },
  241. mounted () {
  242. const _this = this
  243. this.$nextTick(() => { // 页面渲染完成后的回调
  244. _this.setTableH()
  245. })
  246. },
  247. watch: {
  248. advanced (newValue, oldValue) {
  249. const _this = this
  250. setTimeout(() => {
  251. _this.setTableH()
  252. }, 400)
  253. }
  254. },
  255. activated () {
  256. // 如果是新页签打开,则重置当前页面
  257. if (this.$store.state.app.isNewTab) {
  258. this.resetSearchForm()
  259. }
  260. },
  261. beforeRouteEnter (to, from, next) {
  262. next(vm => {
  263. vm.getWarehouseList()
  264. if (!vm.disabled) {
  265. vm.$refs.table.refresh()
  266. }
  267. })
  268. }
  269. }
  270. </script>