list.vue 15 KB

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