list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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-input id="warehousingAuditList-allocationWarehouseNo" v-model.trim="queryParam.allocationWarehouseNo" allowClear placeholder="请输入单号"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="调出仓库">
  20. <a-select id="warehouseAllocation-basicInfo-outWarehouseSn" allowClear placeholder="请选择调出仓库" v-model="queryParam.outWarehouseSn">
  21. <a-select-option v-for="(item, index) in warehouseList" :key="index" :value="item.warehouseSn">{{ item.name }}</a-select-option>
  22. </a-select>
  23. </a-form-item>
  24. </a-col>
  25. <template v-if="advanced">
  26. <a-col :md="6" :sm="24">
  27. <a-form-item label="调入仓库">
  28. <a-select id="warehouseAllocation-basicInfo-putWarehouseSn" allowClear placeholder="请选择调入仓库" v-model="queryParam.putWarehouseSn">
  29. <a-select-option v-for="(item, index) in warehouseList" :key="index" :value="item.warehouseSn">{{ item.name }}</a-select-option>
  30. </a-select>
  31. </a-form-item>
  32. </a-col>
  33. <a-col :md="6" :sm="24">
  34. <a-form-item label="业务状态">
  35. <v-select
  36. v-model="queryParam.state"
  37. ref="state"
  38. id="warehouseAllocationList-state"
  39. code="ALLOCATION_WAREHOUSE_STATE"
  40. placeholder="请选择业务状态"
  41. allowClear
  42. ></v-select>
  43. </a-form-item>
  44. </a-col>
  45. </template>
  46. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  47. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="warehouseAllocationList-refresh">查询</a-button>
  48. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="warehouseAllocationList-reset">重置</a-button>
  49. <a-button
  50. type="primary"
  51. style="margin-left: 5px"
  52. @click="handleExport"
  53. :disabled="disabled"
  54. :loading="exportLoading"
  55. class="button-warning"
  56. v-if="$hasPermissions('B_allocWarehouseExport')"
  57. id="warehouseAllocation-export-btn">导出</a-button>
  58. <a @click="advanced = !advanced" style="margin-left: 8px">
  59. {{ advanced ? '收起' : '展开' }}
  60. <a-icon :type="advanced ? 'up' : 'down'" />
  61. </a>
  62. </a-col>
  63. </a-row>
  64. </a-form>
  65. </div>
  66. <!-- 操作按钮 -->
  67. <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>
  68. <!-- 统计 -->
  69. <a-alert type="info" style="margin-bottom:10px">
  70. <div slot="message">
  71. 总款数: <strong>{{ countData&&(countData.productTotalCategory || countData.productTotalCategory==0) ? countData.productTotalCategory : '--' }}</strong> ,
  72. 总数量: <strong>{{ countData&&(countData.productTotalQty || countData.productTotalQty==0) ? countData.productTotalQty : '--' }}</strong>
  73. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  74. ,总成本: <strong>{{ countData&&(countData.productTotalCost || countData.productTotalCost==0) ? toThousands(countData.productTotalCost,2) : '--' }}</strong>
  75. </div>
  76. </div>
  77. </a-alert>
  78. <!-- 列表 -->
  79. <s-table
  80. class="sTable fixPagination"
  81. ref="table"
  82. :style="{ height: tableHeight+84.5+'px' }"
  83. size="small"
  84. :rowKey="record => record.id"
  85. :columns="columns"
  86. :data="loadData"
  87. :scroll="{ y: tableHeight }"
  88. :defaultLoadData="false"
  89. bordered>
  90. <!-- 单号 -->
  91. <template slot="allocationWarehouseNo" slot-scope="text, record">
  92. <span class="table-td-link" v-if="$hasPermissions('B_warehouseAllocationDetail')" @click="handleDetail(record)">{{ record.allocationWarehouseNo }}</span>
  93. <span v-else>{{ record.allocationWarehouseNo }}</span>
  94. </template>
  95. <!-- 审核 -->
  96. <template slot="audit" slot-scope="text, record">
  97. <stateIcon :title="record.stateDictValue" :state="record.state == 'FINISH'?'1':'2'"></stateIcon>
  98. </template>
  99. <!-- 操作 -->
  100. <template slot="action" slot-scope="text, record">
  101. <a-button
  102. v-if="record.state == 'WAIT_AUDIT'&&$hasPermissions('B_allocWarehouseAudit')"
  103. size="small"
  104. type="link"
  105. class="button-primary"
  106. @click="handleExamine(record)"
  107. id="warehouseAllocationList-examine-btn">
  108. 审核
  109. </a-button>
  110. <a-button
  111. v-if="((record.state == 'WAIT_SUBMIT') || (record.state == 'WAIT_AUDIT')) && $hasPermissions('B_warehouseAllocationEdit')"
  112. size="small"
  113. type="link"
  114. class="button-primary"
  115. @click="handleEdit(record,1)"
  116. id="warehouseAllocationList-edit-btn">
  117. 编辑
  118. </a-button>
  119. <a-button
  120. v-if="((record.state == 'WAIT_SUBMIT') || (record.state == 'WAIT_AUDIT')) && $hasPermissions('B_warehouseAllocationDel')"
  121. size="small"
  122. type="link"
  123. class="button-error"
  124. @click="handleDel(record)"
  125. id="warehouseAllocationList-del-btn">
  126. 删除
  127. </a-button>
  128. <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>
  129. </template>
  130. </s-table>
  131. </a-spin>
  132. <!-- 新增/编辑 -->
  133. <basic-info-modal :openModal="openModal" @ok="handleEdit" @close="openModal=false" />
  134. </a-card>
  135. </template>
  136. <script>
  137. import { commonMixin } from '@/utils/mixin'
  138. import { allocWarehouseList, allocWarehouseAudit, allocWarehouseDel, allocWarehouseQueryCount, allocWarehouseExport } from '@/api/allocWarehouse'
  139. import { warehouseAllList } from '@/api/warehouse.js'
  140. import { STable, VSelect } from '@/components'
  141. import basicInfoModal from './basicInfoModal.vue'
  142. import rangeDate from '@/views/common/rangeDate.vue'
  143. import stateIcon from '@/views/common/stateIcon'
  144. import { downloadExcel } from '@/libs/JGPrint.js'
  145. import getDate from '@/libs/getDate.js'
  146. export default {
  147. name: 'AllocWarehouseList',
  148. components: { STable, VSelect, basicInfoModal, rangeDate, stateIcon },
  149. mixins: [commonMixin],
  150. data () {
  151. return {
  152. spinning: false,
  153. advanced: true, // 高级搜索 展开/关闭
  154. tableHeight: 0,
  155. warehouseList: [], // 仓库列表
  156. time: [
  157. getDate.getCurrMonthDays().starttime,
  158. getDate.getCurrMonthDays().endtime
  159. ],
  160. queryParam: { // 查询条件
  161. beginDate: getDate.getCurrMonthDays().starttime,
  162. endDate: getDate.getCurrMonthDays().endtime,
  163. outWarehouseSn: undefined, // 调出仓库
  164. putWarehouseSn: undefined, // 调入仓库
  165. state: undefined, // 审核状态
  166. allocationWarehouseNo: undefined// 单号
  167. },
  168. disabled: false, // 查询、重置按钮是否可操作
  169. exportLoading: false, // 导出
  170. // 加载数据方法 必须为 Promise 对象
  171. loadData: parameter => {
  172. this.disabled = true
  173. this.spinning = true
  174. const params = Object.assign(parameter, this.queryParam)
  175. return allocWarehouseList(params).then(res => {
  176. let data
  177. if (res.status == 200) {
  178. data = res.data
  179. this.getCount(params)
  180. const no = (data.pageNo - 1) * data.pageSize
  181. for (var i = 0; i < data.list.length; i++) {
  182. data.list[i].no = no + i + 1
  183. }
  184. this.disabled = false
  185. }
  186. this.spinning = false
  187. return data
  188. })
  189. },
  190. openModal: false, // 新增编辑 弹框
  191. countData: null// 统计数据
  192. }
  193. },
  194. computed: {
  195. columns () {
  196. const _this = this
  197. const arr = [
  198. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  199. { title: '创建时间', dataIndex: 'createDate', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  200. { title: '单号', scopedSlots: { customRender: 'allocationWarehouseNo' }, width: '15%', align: 'center' },
  201. { title: '调出仓库', dataIndex: 'outWarehouseName', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  202. { title: '调入仓库', dataIndex: 'putWarehouseName', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  203. { title: '总款数', dataIndex: 'productTotalCategory', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  204. { title: '总数量', dataIndex: 'productTotalQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  205. // { title: '总成本', dataIndex: 'productTotalCost', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  206. { title: '审核时间', dataIndex: 'auditTime', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  207. { title: '业务状态', dataIndex: 'stateDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  208. { title: '审核', scopedSlots: { customRender: 'audit' }, width: '3%', align: 'center' },
  209. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  210. ]
  211. if (this.$hasPermissions('M_ShowAllCost')) {
  212. arr.splice(7, 0, { title: '总成本', dataIndex: 'productTotalCost', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
  213. }
  214. return arr
  215. }
  216. },
  217. methods: {
  218. // 统计
  219. getCount (params) {
  220. allocWarehouseQueryCount(params).then(res => {
  221. if (res.status == 200) {
  222. this.countData = res.data
  223. } else {
  224. this.countData = null
  225. }
  226. })
  227. },
  228. // 时间 change
  229. dateChange (date) {
  230. this.queryParam.beginDate = date[0]
  231. this.queryParam.endDate = date[1]
  232. },
  233. // 获取仓库列表
  234. getWarehouseList () {
  235. warehouseAllList({}).then(res => {
  236. if (res.status == 200) {
  237. this.warehouseList = res.data || []
  238. } else {
  239. this.warehouseList = []
  240. }
  241. })
  242. },
  243. // 重置
  244. resetSearchForm () {
  245. this.resetData()
  246. this.$refs.table.refresh(true)
  247. },
  248. // 重置数据
  249. resetData (flag) {
  250. this.$refs.rangeDate.resetDate(flag ? '' : this.time)
  251. this.queryParam.beginDate = flag ? '' : getDate.getCurrMonthDays().starttime
  252. this.queryParam.endDate = flag ? '' : getDate.getCurrMonthDays().endtime
  253. this.queryParam.outWarehouseSn = undefined
  254. this.queryParam.putWarehouseSn = undefined
  255. this.queryParam.state = undefined
  256. this.queryParam.allocationWarehouseNo = undefined
  257. if (!flag) {
  258. this.setIsHomeNav(this.$route.name, null)
  259. }
  260. },
  261. // 删除
  262. handleDel (row) {
  263. const _this = this
  264. this.$confirm({
  265. title: '提示',
  266. content: '删除后不可恢复,确定要进行删除吗?',
  267. centered: true,
  268. onOk () {
  269. _this.spinning = true
  270. allocWarehouseDel({ id: row.id }).then(res => {
  271. if (res.status == 200) {
  272. _this.$message.success(res.message)
  273. _this.$refs.table.refresh()
  274. _this.spinning = false
  275. } else {
  276. _this.spinning = false
  277. }
  278. })
  279. }
  280. })
  281. },
  282. // 审核
  283. handleExamine (row) {
  284. const _this = this
  285. this.$confirm({
  286. title: '提示',
  287. content: '确认要审核通过吗?',
  288. centered: true,
  289. onOk () {
  290. _this.spinning = true
  291. allocWarehouseAudit({ allocationWarehouseSn: row.allocationWarehouseSn }).then(res => {
  292. if (res.status == 200) {
  293. _this.$message.success(res.message)
  294. _this.$refs.table.refresh()
  295. _this.spinning = false
  296. } else {
  297. _this.spinning = false
  298. }
  299. })
  300. }
  301. })
  302. },
  303. // 详情
  304. handleDetail (row) {
  305. this.$router.push({ path: `/allocationManagement/warehouseAllocation/detail/${row.allocationWarehouseSn}` })
  306. },
  307. // 新增/编辑
  308. handleEdit (row, flag) {
  309. if (!flag) {
  310. this.resetData()
  311. }
  312. this.$router.push({ path: `/allocationManagement/warehouseAllocation/edit/${row.id}/${row.allocationWarehouseSn}` })
  313. },
  314. // 导出
  315. handleExport () {
  316. const _this = this
  317. const params = _this.queryParam
  318. params.showCost = _this.$hasPermissions('M_ShowAllCost') ? 1 : 0
  319. _this.exportLoading = true
  320. _this.spinning = true
  321. allocWarehouseExport(params).then(res => {
  322. downloadExcel(res, '仓库调拨列表')
  323. _this.exportLoading = false
  324. _this.spinning = false
  325. })
  326. },
  327. pageInit () {
  328. const _this = this
  329. this.$nextTick(() => { // 页面渲染完成后的回调
  330. _this.setTableH()
  331. })
  332. this.getWarehouseList()
  333. // 是否打开的页签
  334. const a = this.$store.state.app.isNewTab
  335. // 是否要刷新列表
  336. const b = this.$store.state.app.updateList
  337. // 是否从首页点击进入
  338. const isHomeNav = this.getIsHomeNav()[this.$route.name]
  339. console.log(a, b, this.getIsHomeNav(), isHomeNav, this.$route.name)
  340. // 从首页进入,判断式新建还式待办查询
  341. if (isHomeNav) {
  342. // 新增
  343. if (isHomeNav.type == 'new') {
  344. this.resetSearchForm()
  345. this.openModal = true
  346. }
  347. // 待办
  348. if (isHomeNav.type == 'todo') {
  349. this.resetData(true)
  350. this.queryParam = Object.assign(this.queryParam, isHomeNav.pageParams)
  351. this.$refs.rangeDate.resetDate([this.queryParam.beginDate, this.queryParam.endDate])
  352. this.$refs.table.refresh(true)
  353. }
  354. } else {
  355. // 如果是新页签打开,则重置当前页面
  356. if (a && !b) {
  357. this.resetSearchForm()
  358. }
  359. }
  360. // 仅刷新列表,不重置页面
  361. if (b || a == b) {
  362. this.$refs.table.refresh()
  363. }
  364. },
  365. setTableH () {
  366. const tableSearchH = this.$refs.tableSearch.offsetHeight
  367. this.tableHeight = window.innerHeight - tableSearchH - 273
  368. }
  369. },
  370. watch: {
  371. advanced (newValue, oldValue) {
  372. const _this = this
  373. this.$nextTick(() => { // 页面渲染完成后的回调
  374. _this.setTableH()
  375. })
  376. },
  377. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  378. this.setTableH()
  379. }
  380. },
  381. mounted () {
  382. },
  383. activated () {
  384. this.pageInit()
  385. },
  386. beforeRouteEnter (to, from, next) {
  387. next(vm => {})
  388. }
  389. }
  390. </script>