¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <basic-container> |
| | | <avue-crud ref="crud" |
| | | v-loading="loading" |
| | | :data="data" |
| | | :option="option" |
| | | :page="page" |
| | | @sort-change="sortChange" |
| | | @selection-change="selectionChange" |
| | | @on-load="onLoad"> |
| | | <template slot="menu"> |
| | | <el-button type="text">æåæé®</el-button> |
| | | </template> |
| | | <template slot="menuLeft"> |
| | | <div> |
| | | <el-table :data="tableData" style="width: 100%" @cell-click="handleCellClick" @cell-dblclick="dbclick"> |
| | | <div v-for="(item,index) in this.tableHeadData" :key="index"> |
| | | <el-table-column :label="item.label" :prop="item.prop"> |
| | | <!-- ç¼è¾åå±ç¤ºé»è¾ --> |
| | | <template slot-scope="{ row }"> |
| | | <el-input v-if="editingRow === row && editShow== item.prop" v-model="row[item.prop]" @blur="saveRow"></el-input> |
| | | <span v-else>{{row[item.prop]}}</span> |
| | | </template> |
| | | </el-table-column> |
| | | </div> |
| | | <el-table-column fixed="right" label="æä½" width="120"> |
| | | <template slot-scope="scope"> |
| | | <el-button size="small" type="text" @click.native.prevent="enumDeleteRow(scope.$index, tableData)"> |
| | | ç§»é¤ |
| | | </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <template> |
| | | <div style="display: flex;justify-content: right;margin-top: 15px"> |
| | | <el-button type="primary" size="small">ä¿å</el-button> |
| | | <el-button size="small" @click="enumVisible=false">åæ¶</el-button> |
| | | </div> |
| | | </template> |
| | | </div> |
| | | </template> |
| | | </avue-crud> |
| | | </basic-container> |
| | | </template> |
| | | |
| | | <script> |
| | | import {MasterTable, TableData} from "@/api/GetItem"; |
| | | |
| | | export default { |
| | | name: "Crud.vue", |
| | | data() { |
| | | return { |
| | | editingRow:null, |
| | | editShow: "", |
| | | editAttr:"", |
| | | loading: false, |
| | | data: [], |
| | | option: { |
| | | //é»è®¤é«åº¦, |
| | | align: 'center', |
| | | menuAlign: 'center', |
| | | addBtn: false, |
| | | editBtn: false, |
| | | selection: true, |
| | | selectionFixed: false, |
| | | index: true, |
| | | column: [] |
| | | }, |
| | | List: [], |
| | | columnType: { |
| | | text: "input", |
| | | combox: "select", |
| | | truefalse: "switch", |
| | | number: "number", |
| | | datetime: "datetime", |
| | | }, |
| | | page: { |
| | | total: 0, |
| | | currentPage: 1, |
| | | pageSize: 10, |
| | | pageSizes: [10, 30, 50, 100, 200], |
| | | }, |
| | | tableData:[], |
| | | tableHeadData:[], |
| | | items:{} |
| | | } |
| | | }, |
| | | computed:{ |
| | | editable(){ |
| | | this.tableData.forEach(item=>{ |
| | | this.items=item |
| | | }) |
| | | return this.editShow === this.editingRow[this.items.prop]; |
| | | } |
| | | }, |
| | | created() { |
| | | this.CrudHeaderRend(); |
| | | this.CrudRend() |
| | | }, |
| | | activated() { |
| | | this.doLayout() |
| | | }, |
| | | methods: { |
| | | // çå¬åå
æ ¼ç¹å»äºä»¶å¹¶å卿£å¨ç¼è¾çè¡ |
| | | handleCellClick(row, column) { |
| | | this.editingRow = row; |
| | | this.editShow = column.property; |
| | | console.log( this.editingRow['name'], this.editShow) |
| | | }, |
| | | //æä¸¾æ³¨å
¥å é¤ |
| | | enumDeleteRow(row) { |
| | | console.log(row) |
| | | this.tableData.splice(row, 1) |
| | | }, |
| | | // å°æ£å¨ç¼è¾çè¡çç¶æå为 null ï¼å³éåºç¼è¾ç¶æ |
| | | saveRow() { |
| | | this.editingRow = null; |
| | | }, |
| | | doLayout() { |
| | | this.$nextTick(() => { |
| | | this.$refs.crud.doLayout(); |
| | | }); |
| | | }, |
| | | //è¡¨æ ¼å¤´æ¸²æ |
| | | CrudHeaderRend() { |
| | | MasterTable({ |
| | | codeClassifyOid: "D9CF223F-317D-71EB-BD11-433A94CAD9F3", |
| | | functionId: 5, |
| | | _: 1685067339479 |
| | | }).then(res => { |
| | | this.List = res.data.tableDefineVO.cols[0]; |
| | | this.List.forEach(item => { |
| | | let columnItem = { |
| | | label: item.title, |
| | | prop: item.field, |
| | | type: this.columnType[item.type], |
| | | sortable: item.sort, |
| | | width: item.minWidth |
| | | }; |
| | | this.option.column.push(columnItem); |
| | | this.option.column=this.tableHeadData; |
| | | }) |
| | | }) |
| | | }, |
| | | //è¡¨æ ¼æ°æ® |
| | | CrudRend() { |
| | | TableData({ |
| | | templateOid: "A12826E4-2B66-6D56-DE30-92BB1D7F607F", |
| | | codeClassifyOid: "D9CF223F-317D-71EB-BD11-433A94CAD9F3", |
| | | page: this.page.currentPage, |
| | | limit: this.page.pageSize, |
| | | _: 1685089123575 |
| | | }).then(res => { |
| | | this.page.total = res.data.total; |
| | | this.data = res.data.data; |
| | | this.tableData=res.data.data; |
| | | }) |
| | | }, |
| | | // æåº |
| | | sortChange(val) { |
| | | this.loading = true; |
| | | let order = "" |
| | | if (val.order == "ascending") { |
| | | order = "asc"; |
| | | } else { |
| | | order = "desc"; |
| | | } |
| | | TableData({ |
| | | templateOid: "A12826E4-2B66-6D56-DE30-92BB1D7F607F", |
| | | codeClassifyOid: "D9CF223F-317D-71EB-BD11-433A94CAD9F3", |
| | | order: order, |
| | | sort: val.prop, |
| | | page: this.page.currentPage, |
| | | limit: this.page.pageSize, |
| | | }).then(res => { |
| | | setTimeout(() => { |
| | | this.data = res.data.data; |
| | | this.loading = false; |
| | | }, 100); |
| | | }) |
| | | }, |
| | | //å页巿° |
| | | async onLoad(val) { |
| | | console.log(val) |
| | | await TableData({ |
| | | templateOid: "A12826E4-2B66-6D56-DE30-92BB1D7F607F", |
| | | codeClassifyOid: "D9CF223F-317D-71EB-BD11-433A94CAD9F3", |
| | | page: val.currentPage, |
| | | limit: val.pageSize, |
| | | _: 1685089123575 |
| | | }).then(res => { |
| | | this.data = res.data.data; |
| | | }) |
| | | }, |
| | | //å¤é |
| | | selectionChange(row) { |
| | | console.log(row) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |