list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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="4" :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="4" :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="4" :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 class="table-td-link" v-if="$hasPermissions('B_warehouseAllocationDetail')" @click="handleDetail(record)">{{ record.allocationWarehouseNo }}</span>
  69. <span v-else>{{ record.allocationWarehouseNo }}</span>
  70. </template>
  71. <!-- 审核 -->
  72. <template slot="audit" slot-scope="text, record">
  73. <stateIcon :title="record.stateDictValue" :state="record.state == 'FINISH'?'1':'2'"></stateIcon>
  74. </template>
  75. <!-- 操作 -->
  76. <template slot="action" slot-scope="text, record">
  77. <a-button
  78. v-if="record.state == 'WAIT_AUDIT'&&$hasPermissions('B_allocWarehouseAudit')"
  79. size="small"
  80. type="link"
  81. class="button-primary"
  82. @click="handleExamine(record)"
  83. id="warehouseAllocationList-examine-btn">
  84. 审核
  85. </a-button>
  86. <a-button
  87. v-if="((record.state == 'WAIT_SUBMIT') || (record.state == 'WAIT_AUDIT')) && $hasPermissions('B_warehouseAllocationEdit')"
  88. size="small"
  89. type="link"
  90. class="button-primary"
  91. @click="handleEdit(record,1)"
  92. id="warehouseAllocationList-edit-btn">
  93. 编辑
  94. </a-button>
  95. <a-button
  96. v-if="((record.state == 'WAIT_SUBMIT') || (record.state == 'WAIT_AUDIT')) && $hasPermissions('B_warehouseAllocationDel')"
  97. size="small"
  98. type="link"
  99. class="button-error"
  100. @click="handleDel(record)"
  101. id="warehouseAllocationList-del-btn">
  102. 删除
  103. </a-button>
  104. <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>
  105. </template>
  106. </s-table>
  107. </a-spin>
  108. <!-- 新增/编辑 -->
  109. <basic-info-modal :openModal="openModal" @ok="handleEdit" @close="openModal=false" />
  110. </a-card>
  111. </template>
  112. <script>
  113. import { commonMixin } from '@/utils/mixin'
  114. import { allocWarehouseList, allocWarehouseAudit, allocWarehouseDel } from '@/api/allocWarehouse'
  115. import { warehouseAllList } from '@/api/warehouse.js'
  116. import { STable, VSelect } from '@/components'
  117. import basicInfoModal from './basicInfoModal.vue'
  118. import rangeDate from '@/views/common/rangeDate.vue'
  119. import stateIcon from '@/views/common/stateIcon'
  120. import getDate from '@/libs/getDate.js'
  121. export default {
  122. name: 'AllocWarehouseList',
  123. components: { STable, VSelect, basicInfoModal, rangeDate, stateIcon },
  124. mixins: [commonMixin],
  125. data () {
  126. return {
  127. spinning: false,
  128. advanced: true, // 高级搜索 展开/关闭
  129. tableHeight: 0,
  130. warehouseList: [], // 仓库列表
  131. time: [
  132. getDate.getCurrMonthDays().starttime,
  133. getDate.getCurrMonthDays().endtime
  134. ],
  135. queryParam: { // 查询条件
  136. beginDate: getDate.getCurrMonthDays().starttime,
  137. endDate: getDate.getCurrMonthDays().endtime,
  138. outWarehouseSn: undefined, // 调出仓库
  139. putWarehouseSn: undefined, // 调入仓库
  140. state: undefined // 审核状态
  141. },
  142. disabled: false, // 查询、重置按钮是否可操作
  143. // 加载数据方法 必须为 Promise 对象
  144. loadData: parameter => {
  145. this.disabled = true
  146. this.spinning = true
  147. return allocWarehouseList(Object.assign(parameter, this.queryParam)).then(res => {
  148. let data
  149. if (res.status == 200) {
  150. data = res.data
  151. const no = (data.pageNo - 1) * data.pageSize
  152. for (var i = 0; i < data.list.length; i++) {
  153. data.list[i].no = no + i + 1
  154. }
  155. this.disabled = false
  156. }
  157. this.spinning = false
  158. return data
  159. })
  160. },
  161. openModal: false // 新增编辑 弹框
  162. }
  163. },
  164. computed: {
  165. columns () {
  166. const arr = [
  167. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  168. { title: '创建时间', dataIndex: 'createDate', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  169. { title: '单号', scopedSlots: { customRender: 'allocationWarehouseNo' }, width: '15%', align: 'center' },
  170. { title: '调出仓库', dataIndex: 'outWarehouseName', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  171. { title: '调入仓库', dataIndex: 'putWarehouseName', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  172. { title: '总款数', dataIndex: 'productTotalCategory', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  173. { title: '总数量', dataIndex: 'productTotalQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  174. // { title: '总成本', dataIndex: 'productTotalCost', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  175. { title: '审核时间', dataIndex: 'auditTime', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  176. { title: '业务状态', dataIndex: 'stateDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  177. { title: '审核', scopedSlots: { customRender: 'audit' }, width: '3%', align: 'center' },
  178. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  179. ]
  180. if (this.$hasPermissions('M_ShowAllCost')) {
  181. arr.splice(7, 0, { title: '总成本', dataIndex: 'productTotalCost', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  182. }
  183. return arr
  184. }
  185. },
  186. methods: {
  187. // 时间 change
  188. dateChange (date) {
  189. this.queryParam.beginDate = date[0]
  190. this.queryParam.endDate = date[1]
  191. },
  192. // 获取仓库列表
  193. getWarehouseList () {
  194. warehouseAllList({}).then(res => {
  195. if (res.status == 200) {
  196. this.warehouseList = res.data || []
  197. } else {
  198. this.warehouseList = []
  199. }
  200. })
  201. },
  202. // 重置
  203. resetSearchForm () {
  204. this.resetData()
  205. this.$refs.table.refresh(true)
  206. },
  207. // 重置数据
  208. resetData (flag) {
  209. this.$refs.rangeDate.resetDate(flag ? '' : this.time)
  210. this.queryParam.beginDate = flag ? '' : getDate.getCurrMonthDays().starttime
  211. this.queryParam.endDate = flag ? '' : getDate.getCurrMonthDays().endtime
  212. this.queryParam.outWarehouseSn = undefined
  213. this.queryParam.putWarehouseSn = undefined
  214. this.queryParam.state = undefined
  215. if (!flag) {
  216. this.setIsHomeNav(this.$route.name, null)
  217. }
  218. },
  219. // 删除
  220. handleDel (row) {
  221. const _this = this
  222. this.$confirm({
  223. title: '提示',
  224. content: '删除后不可恢复,确定要进行删除吗?',
  225. centered: true,
  226. onOk () {
  227. _this.spinning = true
  228. allocWarehouseDel({ id: row.id }).then(res => {
  229. if (res.status == 200) {
  230. _this.$message.success(res.message)
  231. _this.$refs.table.refresh()
  232. _this.spinning = false
  233. } else {
  234. _this.spinning = false
  235. }
  236. })
  237. }
  238. })
  239. },
  240. // 审核
  241. handleExamine (row) {
  242. const _this = this
  243. this.$confirm({
  244. title: '提示',
  245. content: '确认要审核通过吗?',
  246. centered: true,
  247. onOk () {
  248. _this.spinning = true
  249. allocWarehouseAudit({ allocationWarehouseSn: row.allocationWarehouseSn }).then(res => {
  250. if (res.status == 200) {
  251. _this.$message.success(res.message)
  252. _this.$refs.table.refresh()
  253. _this.spinning = false
  254. } else {
  255. _this.spinning = false
  256. }
  257. })
  258. }
  259. })
  260. },
  261. // 详情
  262. handleDetail (row) {
  263. this.$router.push({ path: `/allocationManagement/warehouseAllocation/detail/${row.allocationWarehouseSn}` })
  264. },
  265. // 新增/编辑
  266. handleEdit (row, flag) {
  267. if (!flag) {
  268. this.resetData()
  269. }
  270. this.$router.push({ path: `/allocationManagement/warehouseAllocation/edit/${row.id}/${row.allocationWarehouseSn}` })
  271. },
  272. pageInit () {
  273. const _this = this
  274. this.$nextTick(() => { // 页面渲染完成后的回调
  275. _this.setTableH()
  276. })
  277. this.getWarehouseList()
  278. // 是否打开的页签
  279. const a = this.$store.state.app.isNewTab
  280. // 是否要刷新列表
  281. const b = this.$store.state.app.updateList
  282. // 是否从首页点击进入
  283. const isHomeNav = this.getIsHomeNav()[this.$route.name]
  284. console.log(a, b, this.getIsHomeNav(), isHomeNav, this.$route.name)
  285. // 从首页进入,判断式新建还式待办查询
  286. if (isHomeNav) {
  287. // 新增
  288. if (isHomeNav.type == 'new') {
  289. this.resetSearchForm()
  290. this.openModal = true
  291. }
  292. // 待办
  293. if (isHomeNav.type == 'todo') {
  294. this.resetData(true)
  295. this.queryParam = Object.assign(this.queryParam, isHomeNav.pageParams)
  296. this.$refs.rangeDate.resetDate([this.queryParam.beginDate, this.queryParam.endDate])
  297. this.$refs.table.refresh(true)
  298. }
  299. } else {
  300. // 如果是新页签打开,则重置当前页面
  301. if (a && !b) {
  302. this.resetSearchForm()
  303. }
  304. }
  305. // 仅刷新列表,不重置页面
  306. if (b) {
  307. this.$refs.table.refresh()
  308. }
  309. },
  310. setTableH () {
  311. const tableSearchH = this.$refs.tableSearch.offsetHeight
  312. this.tableHeight = window.innerHeight - tableSearchH - 235
  313. }
  314. },
  315. watch: {
  316. advanced (newValue, oldValue) {
  317. const _this = this
  318. this.$nextTick(() => { // 页面渲染完成后的回调
  319. _this.setTableH()
  320. })
  321. },
  322. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  323. this.setTableH()
  324. }
  325. },
  326. mounted () {
  327. },
  328. activated () {
  329. this.pageInit()
  330. },
  331. beforeRouteEnter (to, from, next) {
  332. next(vm => {})
  333. }
  334. }
  335. </script>