|
- <template>
- <view class="page">
- <l-customlist-sidepage-datefilter v-model="dateRange" @change="searchChange" title="按申请时间查询: "
- ref="datefilter" class="margin-bottom" />
- <next-table ref="table" :show-header="true" :columns="column" :stripe="true" :fit="false"
- @toggleRowSelection="toggleRowSelection" :showPaging="true" :pageIndex="page" :pageTotal="pageTotal"
- @toggleAllSelection="toggleAllSelection" :border="true" :data="data" @pageChange="pageChange"
- :highlight="true">
- </next-table>
- <l-customform-table :value="currentRowDetail" :item="Purchase_Edu_Details" :edit="false" />
- <view class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;">
- <l-button @click="action('save')" size="lg" color="green" class="block margin-top" block>
- 确定新增
- </l-button>
- <l-button @click="action('cancel')" size="lg" line="red" class="block margin-top" block>
- 取消新增
- </l-button>
- </view>
- </view>
- </template>
-
- <script>
- import get from 'lodash/get'
- import set from 'lodash/set'
- import customPageMixins from '@/common/custompage.js'
- import pickBy from 'lodash/pickBy'
- import mapValues from 'lodash/mapValues'
- export default {
- mixins: [customPageMixins],
- data() {
- return {
- queryData:{},
- searchData:{},
- dateRange:null,
- Purchase_Edu_Details: {
- type: 'girdtable',
- title: '采购列表',
- __defaultItem__: {},
- fieldsData: [{
- field: 'Name',
- type: 'input',
- name: '采购物品名称'
- },
- {
- field: 'Price',
- type: 'input',
- name: '价格'
- },
- {
- field: 'Quantity',
- type: 'input',
- name: '采购数量'
- },
- {
- field: 'Unit',
- type: 'input',
- name: '单位'
- },
- {
- field: 'UseTo',
- type: 'input',
- name: '用途'
- },
- ]
- },
- // 采购数据
- column: [{
- type: 'selection',
- fixed: true,
- width: 60
- },
- {
- name: 'CreatorName',
- label: '申请人',
- width: 80,
- emptyString: '--'
- },
- {
- name: 'TotalAmount',
- label: '采购总价',
- fixed: false,
- width: 86,
- emptyString: '--'
- },
- {
- name: 'DepartmentName',
- label: '部门',
- fixed: false,
- width: 200,
- emptyString: '--'
- },
- {
- name: 'Remark',
- label: '备注',
- fixed: false,
- width: 156,
- emptyString: '--'
- },
- {
- name: 'SubmitTime',
- label: '提交时间',
- fixed: false,
- width: 146,
- emptyString: '--'
- },
- {
- name: 'CheckTime',
- label: '审核时间',
- fixed: false,
- width: 146,
- emptyString: '--'
- },
- ],
- formHasData:[],
- checkedObj: {},
- data: [],
- page: 1,
- total: 2,
- rows: 8,
- list: [],
- currentRowDetail: [],
- }
- },
- computed: {
- pageTotal() {
- if (this.total > this.rows) {
- return Math.ceil(this.total / this.rows)
- } else {
- return 1
- }
- }
- },
- mounted() {
- this.init()
- },
- methods: {
- init() {
- // let params = this.GET_PARAM()
- // this.formHasData = params || []
- this.fetchList()
- },
-
- // 采购列表
- async fetchList() {
- if (this.page > this.total) {
- return
- }
- const result = await this.HTTP_GET(
- 'learun/adms/purchasetravel/pagelist', {
- // 这里 sidx 表示排序字段,sord 表示排序方式(DESC=降序,ASC=升序)
- // 代码生成器生成时默认按照主键排序,您可以修改成按创建时间的字段降序
- pagination: {
- rows: this.rows,
- page: this.page,
- sidx: 'CreateTime',
- sord: 'DESC'
- },
- queryJson: JSON.stringify({
- ...this.searchData,
- ApplyStatus: 0,
- CheckStatus: 2
- })
- },
- '加载数据时出错'
- )
- if (!result) {
- return
- }
-
- this.total = result.records
- this.page = result.page
- this.data = result.rows.map(e => {
- if (this.checkedObj[this.page] && this.checkedObj[this.page].find(e1=>e.Id == e1.Id)) {
- e.checked = true
- }
- return e
- });
- },
- toggleAllSelection(_, list) {
- this.checkedObj[this.page] = list
- },
- toggleRowSelection(bool, list) {
- this.checkedObj[this.page] = list
- },
- pageChange(index) {
- this.$refs.table.resetHighlight()
- this.currentRowDetail = []
- this.page = index
- this.fetchList()
- },
- async currentChange(row) {
- this.currentRowDetail = []
- const result = await this.HTTP_GET('learun/adms/purchasetravel/formdetail', row.Id)
- if (!result) return
- this.currentRowDetail = result
- },
- async action(type) {
- switch (type) {
- case 'save':
- let arr = []
- for(let key in this.checkedObj){
- arr = arr.concat(this.checkedObj[key] || [])
- }
- this.EMIT('details-change',arr)
- this.NAV_BACK()
- break
- case 'cancel':
- this.NAV_BACK()
- break
- default:
- break
- }
- },
-
- // 设置搜索条件
- async searchChange() {
- const result = {}
-
- // 时间查询相关参数
- if (this.dateRange) {
- result.StartTime = this.dateRange.start
- result.EndTime = this.dateRange.end
- }
- // 将其他查询项添加到查询 JSON 中
- const queryObj = pickBy(this.queryData, t => (Array.isArray(t) ? t.length > 0 : t))
- Object.assign(result, mapValues(queryObj, t => (Array.isArray(t) ? t.join(',') : t)))
-
- this.searchData = result
- await this.refreshList(false)
- },
- // 刷新清空列表
- async refreshList(isConcat = true) {
- this.page = 1
- this.total = 2
- this.list = []
- this.currentRowDetail = []
- this.checkedObj = {}
- this.$refs.table.resetHighlight()
- await this.fetchList(isConcat)
- },
- // 设置表单值
- setValue(path, val) {
- set(this.current, path, val)
- },
- }
- }
- </script>
-
- <style>
- </style>
|