list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. :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. export default {
  115. components: { STable, VSelect, basicInfoModal, rangeDate },
  116. data () {
  117. return {
  118. spinning: false,
  119. advanced: true, // 高级搜索 展开/关闭
  120. tableHeight: 0,
  121. warehouseList: [], // 仓库列表
  122. queryParam: { // 查询条件
  123. beginDate: '',
  124. endDate: '',
  125. outWarehouseSn: undefined, // 调出仓库
  126. putWarehouseSn: undefined, // 调入仓库
  127. state: undefined // 审核状态
  128. },
  129. disabled: false, // 查询、重置按钮是否可操作
  130. columns: [
  131. { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
  132. { title: '创建时间', dataIndex: 'createDate', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  133. { title: '单号', scopedSlots: { customRender: 'allocationWarehouseNo' }, width: 140, align: 'center' },
  134. { title: '调出仓库', dataIndex: 'outWarehouseName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  135. { title: '调入仓库', dataIndex: 'putWarehouseName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  136. { title: '总款数', dataIndex: 'productTotalCategory', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  137. { title: '总数量', dataIndex: 'productTotalQty', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  138. { title: '总成本', dataIndex: 'productTotalCost', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  139. { title: '审核时间', dataIndex: 'auditTime', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  140. { title: '业务状态', dataIndex: 'stateDictValue', width: 80, align: 'center', customRender: function (text) { return text || '--' } },
  141. { title: '操作', scopedSlots: { customRender: 'action' }, width: 150, align: 'center', fixed: 'right' }
  142. ],
  143. // 加载数据方法 必须为 Promise 对象
  144. loadData: parameter => {
  145. this.disabled = true
  146. this.spinning = true
  147. return allocWarehouseList(Object.assign(parameter, this.queryParam)).then(res => {
  148. const data = res.data
  149. const no = (data.pageNo - 1) * data.pageSize
  150. for (var i = 0; i < data.list.length; i++) {
  151. data.list[i].no = no + i + 1
  152. }
  153. this.disabled = false
  154. this.spinning = false
  155. return data
  156. })
  157. },
  158. openModal: false // 新增编辑 弹框
  159. }
  160. },
  161. methods: {
  162. // 时间 change
  163. dateChange (date) {
  164. this.queryParam.beginDate = date[0]
  165. this.queryParam.endDate = date[1]
  166. },
  167. // 获取仓库列表
  168. getWarehouseList () {
  169. warehouseAllList({}).then(res => {
  170. if (res.status == 200) {
  171. this.warehouseList = res.data || []
  172. } else {
  173. this.warehouseList = []
  174. }
  175. })
  176. },
  177. // 重置
  178. resetSearchForm () {
  179. this.$refs.rangeDate.resetDate()
  180. this.queryParam.beginDate = ''
  181. this.queryParam.endDate = ''
  182. this.queryParam.outWarehouseSn = undefined
  183. this.queryParam.putWarehouseSn = undefined
  184. this.queryParam.state = undefined
  185. this.$refs.table.refresh(true)
  186. },
  187. // 删除
  188. handleDel (row) {
  189. const _this = this
  190. this.$confirm({
  191. title: '提示',
  192. content: '删除后不可恢复,确定要进行删除吗?',
  193. centered: true,
  194. onOk () {
  195. _this.spinning = true
  196. allocWarehouseDel({ id: row.id }).then(res => {
  197. if (res.status == 200) {
  198. _this.$message.success(res.message)
  199. _this.$refs.table.refresh()
  200. _this.spinning = false
  201. } else {
  202. _this.spinning = false
  203. }
  204. })
  205. }
  206. })
  207. },
  208. // 审核
  209. handleExamine (row) {
  210. const _this = this
  211. this.$confirm({
  212. title: '提示',
  213. content: '确认要审核通过吗?',
  214. centered: true,
  215. onOk () {
  216. _this.spinning = true
  217. allocWarehouseAudit({ allocationWarehouseSn: row.allocationWarehouseSn }).then(res => {
  218. if (res.status == 200) {
  219. _this.$message.success(res.message)
  220. _this.$refs.table.refresh()
  221. _this.spinning = false
  222. } else {
  223. _this.spinning = false
  224. }
  225. })
  226. }
  227. })
  228. },
  229. // 详情
  230. handleDetail (row) {
  231. this.$router.push({ path: `/allocationManagement/warehouseAllocation/detail/${row.allocationWarehouseSn}` })
  232. },
  233. // 新增/编辑
  234. handleEdit (row) {
  235. this.$router.push({ path: `/allocationManagement/warehouseAllocation/edit/${row.id}/${row.allocationWarehouseSn}` })
  236. },
  237. pageInit () {
  238. const _this = this
  239. this.$nextTick(() => { // 页面渲染完成后的回调
  240. _this.setTableH()
  241. })
  242. this.getWarehouseList()
  243. },
  244. setTableH () {
  245. const tableSearchH = this.$refs.tableSearch.offsetHeight
  246. this.tableHeight = window.innerHeight - tableSearchH - 235
  247. }
  248. },
  249. watch: {
  250. advanced (newValue, oldValue) {
  251. const _this = this
  252. setTimeout(() => {
  253. _this.setTableH()
  254. }, 400)
  255. }
  256. },
  257. mounted () {
  258. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  259. this.pageInit()
  260. this.resetSearchForm()
  261. }
  262. },
  263. activated () {
  264. // 如果是新页签打开,则重置当前页面
  265. if (this.$store.state.app.isNewTab) {
  266. this.pageInit()
  267. this.resetSearchForm()
  268. }
  269. },
  270. beforeRouteEnter (to, from, next) {
  271. next(vm => {})
  272. }
  273. }
  274. </script>