pengjun 3 weeks ago
parent
commit
4cfb8a3e38
  1. 85
      src/components/commonTable/CommonTable.vue
  2. 37
      src/components/commonTable/CommonTableEdit.vue
  3. 13
      src/components/commonTable/CommonTableTypeEdit.vue
  4. 3
      src/components/commonTable/commonTableType.vue

85
src/components/commonTable/CommonTable.vue

@ -1,20 +1,26 @@
<template> <template>
<div> <div>
<div> <div>
<div class="contenttitle">
明细记录
<div style="display: flex;justify-content: space-between;">
<div class="contenttitle">
明细记录
</div>
<el-input v-model="searchKeyWord" size="small" placeholder="请输入查询关键字" @keyup.native.enter="searchEnter" @input="searchEnter"
style="width: 200px;" />
</div> </div>
<!--公共表分类信息--> <!--公共表分类信息-->
<div style="display: flex; font-size: 14px"> <div style="display: flex; font-size: 14px">
<div :style="'display: block;width:' + (window.pageWidth - window.pageMarginWidth - 110 - 5) + 'px;'"> <div :style="'display: block;width:' + (window.pageWidth - window.pageMarginWidth - 110 - 5) + 'px;'">
<el-table id="commonTables" :data="commonTables" ref="commonTables" row-key="id" border :height="`${tableHeight}px`"
size="small" highlight-current-row :row-class-name="handleRowClassName" @row-click="rowClick" @row-dblclick="dblClick">
<el-table id="commonTables" :data="commonTables" ref="commonTables" row-key="id" border
:height="`${tableHeight}px`" size="small" highlight-current-row :row-class-name="handleRowClassName"
@row-click="rowClick" @row-dblclick="dblClick">
<el-table-column type="index" label="序号" width="50" align="center" /> <el-table-column type="index" label="序号" width="50" align="center" />
<el-table-column label="编号" prop="id" min-width="200" align="center" />
<el-table-column prop="dataCode" label="dataCode" min-width="100" />
<el-table-column prop="displayName" label="项目名称" min-width="150" />
<el-table-column prop="commonTableTypeId" label="分类" min-width="150" />
<el-table-column prop="simpleCode" label="简码" min-width="60" />
<el-table-column label="编号" prop="id" min-width="150" align="center" sortable />
<el-table-column prop="displayName" label="体检系统编码" min-width="150" sortable />
<el-table-column prop="simpleCode" label="体检系统名称" min-width="150" sortable />
<el-table-column v-for="col in Object.keys(commonTableCols)" :prop="col" :label="commonTableCols[col]"
min-width="100" sortable />
<el-table-column prop="commonTableTypeId" label="分类" min-width="150" sortable />
<el-table-column prop="creatorName" label="创建者" min-width="80" align="center" /> <el-table-column prop="creatorName" label="创建者" min-width="80" align="center" />
<el-table-column label="创建时间" min-width="150" align="center"> <el-table-column label="创建时间" min-width="150" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
@ -68,7 +74,7 @@
<!-- 新增或者编辑弹框 --> <!-- 新增或者编辑弹框 -->
<el-dialog :title="dataTransOpts.tableS.common_table.id ? '编辑' : '新增'" :close-on-click-modal="false" <el-dialog :title="dataTransOpts.tableS.common_table.id ? '编辑' : '新增'" :close-on-click-modal="false"
:visible.sync="dialogWin.CommonTableEdit" width="600px" @close="close_dialogWinCommonTableEdit"> :visible.sync="dialogWin.CommonTableEdit" width="600px" @close="close_dialogWinCommonTableEdit">
<CommonTableEdit :params="CommonTableEditParams" />
<CommonTableEdit :params="CommonTableEditParams" :commonTableCols="commonTableCols" />
</el-dialog> </el-dialog>
<!-- --> <!-- -->
</div> </div>
@ -89,10 +95,12 @@ import {
import CommonTableEdit from "./CommonTableEdit.vue"; import CommonTableEdit from "./CommonTableEdit.vue";
export default { export default {
components: { components: {
CommonTableEdit CommonTableEdit
}, },
props: ["refParams"],
data() { data() {
return { return {
pagePriv: { pagePriv: {
@ -101,9 +109,14 @@ export default {
}, },
commonTables: [], // commonTables: [], //
commonTablesAll: [],
curCommonTable: {}, // curCommonTable: {}, //
commonTableCols: {
dataCode: '',
// dataCode2:''
}, //
CommonTableEditParams: {}, // CommonTableEditParams: {}, //
searchKeyWord: "",
isDrag: false, isDrag: false,
clickTime1: 0, clickTime1: 0,
clickTime2: 0 clickTime2: 0
@ -127,6 +140,9 @@ export default {
// ID // ID
this.dataTransOpts.tableS.common_table.id = '' this.dataTransOpts.tableS.common_table.id = ''
//
this.commonTableColsInit()
this.rowDrop(); this.rowDrop();
}, },
@ -141,16 +157,48 @@ export default {
dddw, dddw,
deepCopy, deepCopy,
//
commonTableColsInit() {
// console.log('refParams', this.refParams)
try {
this.commonTableCols = {}
if (this.refParams?.columnName) this.commonTableCols = JSON.parse(this.refParams?.columnName)
} catch (error) {
console.error('公共表多列名转换失败', error)
} finally {
this.commonTableCols.dataCode = this.refParams?.displayName || '第三方对照编码'
}
},
//
searchEnter() {
if (this.searchKeyWord) {
let temp = ''
this.commonTables = this.commonTablesAll.filter(e => {
temp = ''
if (e.displayName) temp += ',' + e.displayName
if (e.simpleCode) temp += ',' + e.simpleCode
Object.keys(this.commonTableCols).forEach(col => {
if (e[col]) temp += ',' + e[col]
});
return temp.includes(this.searchKeyWord)
})
} else {
this.commonTables = this.commonTablesAll
}
},
getList(body) { getList(body) {
// body = { // body = {
// "commonTableTypeId": "string", // "commonTableTypeId": "string",
// "keyWord": "string" // "keyWord": "string"
// } // }
this.commonTables = [] this.commonTables = []
if(!body.commonTableTypeId) return
if (!body.commonTableTypeId) return
postapi('/api/app/CommonTable/GetList', body).then(res => { postapi('/api/app/CommonTable/GetList', body).then(res => {
if (res.code > -1) { if (res.code > -1) {
this.commonTables = res.data this.commonTables = res.data
this.commonTablesAll = res.data
this.rowDrop() this.rowDrop()
} }
}) })
@ -229,7 +277,7 @@ export default {
// //
dictInit() { dictInit() {
}, },
@ -257,7 +305,7 @@ export default {
id, id,
commonTableTypeId: this.dataTransOpts.tableS.common_table_type.id, commonTableTypeId: this.dataTransOpts.tableS.common_table_type.id,
} }
this.dataTransOpts.refresh.common_table.S++
this.dataTransOpts.refresh.common_table.S++
this.dialogWin.CommonTableEdit = true; this.dialogWin.CommonTableEdit = true;
}, },
@ -284,13 +332,13 @@ export default {
type: "warning", type: "warning",
}) })
.then(() => { .then(() => {
return postapi('/api/app/CommonTable/Delete', {commonTableId:this.dataTransOpts.tableS.common_table.id});
return postapi('/api/app/CommonTable/Delete', { commonTableId: this.dataTransOpts.tableS.common_table.id });
}) })
.then((res) => { .then((res) => {
if (res.code != -1) { if (res.code != -1) {
console.log("删除成功"); console.log("删除成功");
let lfind = arrayExistObj(this.commonTables, "id", this.dataTransOpts.tableS.common_table.id); let lfind = arrayExistObj(this.commonTables, "id", this.dataTransOpts.tableS.common_table.id);
if (lfind > -1) this.commonTables.splice(lfind, 1);
if (lfind > -1) this.commonTables.splice(lfind, 1);
} }
}) })
.catch((err) => { .catch((err) => {
@ -340,7 +388,10 @@ export default {
// immediate:true, // immediate:true,
handler(newVal, oldVal) { handler(newVal, oldVal) {
console.log(`watch 公共表分类 newVal:${newVal} oldVal:${oldVal} commonTableTypeId: ${this.dataTransOpts.tableS.common_table_type.id}`); console.log(`watch 公共表分类 newVal:${newVal} oldVal:${oldVal} commonTableTypeId: ${this.dataTransOpts.tableS.common_table_type.id}`);
if (newVal != oldVal) this.getList({ commonTableTypeId: this.dataTransOpts.tableS.common_table_type.id });
if (newVal != oldVal) {
this.commonTableColsInit()
this.getList({ commonTableTypeId: this.dataTransOpts.tableS.common_table_type.id });
}
} }
}, },
}, },

37
src/components/commonTable/CommonTableEdit.vue

@ -1,10 +1,10 @@
<template> <template>
<div> <div>
<el-form :model="form" label-width="80px" :rules="rules" ref="form">
<el-form :model="form" label-width="180px" :rules="rules" ref="form">
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item prop="commonTableTypeId" label="分类"> <el-form-item prop="commonTableTypeId" label="分类">
<el-select v-model="form.commonTableTypeId" placeholder="请选择" size="small">
<el-select v-model="form.commonTableTypeId" placeholder="请选择" size="small" disabled>
<el-option v-for="item in commonTableTypes" :key="item.id" :label="item.displayName" :value="item.id"> <el-option v-for="item in commonTableTypes" :key="item.id" :label="item.displayName" :value="item.id">
</el-option> </el-option>
</el-select> </el-select>
@ -13,18 +13,25 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item prop="dataCode" label="dataCode">
<el-input v-model="form.dataCode" size="small" />
<el-form-item prop="displayName" label="体检系统编码">
<el-input v-model="form.displayName" size="small" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item prop="displayName" label="项目名称">
<el-input v-model="form.displayName" size="small" />
<el-form-item prop="simpleCode" label="体检系统编码">
<el-input v-model="form.simpleCode" size="small" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row v-for="col in Object.keys(commonTableCols)">
<el-col :span="24">
<el-form-item :prop="col" :label="commonTableCols[col]">
<el-input v-model="form[col]" size="small" />
</el-form-item>
</el-col>
</el-row>
</el-form> </el-form>
<div style="display: flex;margin-top: 15px;justify-content:space-between;"> <div style="display: flex;margin-top: 15px;justify-content:space-between;">
<div></div> <div></div>
@ -55,14 +62,23 @@ export default {
components: { components: {
}, },
props: ["params"],
props: ["params","commonTableCols"],
data() { data() {
return { return {
form: { form: {
id: "", id: "",
commonTableTypeId: null, // commonTableTypeId: null, //
displayName: "", displayName: "",
dataCode: ""
simpleCode:"",
dataCode: "",
dataCode2: "",
dataCode3: "",
dataCode4: "",
dataCode5: "",
dataCode6: "",
dataCode7: "",
dataCode8: "",
dataCode9: ""
}, },
editType: 'insert', editType: 'insert',
commonTableTypes: [], // commonTableTypes: [], //
@ -101,6 +117,8 @@ export default {
// //
getFormData(id) { getFormData(id) {
this.$refs['form'].resetFields();
if (id) { if (id) {
postapi('/api/app/CommonTable/Get', { commonTableId: id }) postapi('/api/app/CommonTable/Get', { commonTableId: id })
.then(res => { .then(res => {
@ -110,7 +128,8 @@ export default {
}) })
this.editType = 'update' this.editType = 'update'
} else { } else {
console.log('this.formInit', this.formInit)
// console.log('this.formInit', this.formInit)
// this.form = this.$options.data().form
this.form = Object.assign({}, this.formInit, { commonTableTypeId: this.params.commonTableTypeId }) this.form = Object.assign({}, this.formInit, { commonTableTypeId: this.params.commonTableTypeId })
this.editType = 'insert' this.editType = 'insert'
} }

13
src/components/commonTable/CommonTableTypeEdit.vue

@ -15,6 +15,14 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row>
<el-col :span="24">
<el-form-item prop="columnName" label="多列名配置">
<el-input type="textarea" :rows="4" placeholder="请输入内容" v-model="form.columnName" size="small">
</el-input>
</el-form-item>
</el-col>
</el-row>
</el-form> </el-form>
<div style="display: flex;margin-top: 15px;justify-content:space-between;"> <div style="display: flex;margin-top: 15px;justify-content:space-between;">
<div></div> <div></div>
@ -52,6 +60,7 @@ export default {
form: { form: {
id: "", id: "",
displayName: "", displayName: "",
columnName: ""
}, },
editType: 'insert', // update editType: 'insert', // update
formOri: {}, // formOri: {}, //
@ -66,7 +75,7 @@ export default {
...mapState(["dict", "dialogWin", "dataTransOpts"]), ...mapState(["dict", "dialogWin", "dataTransOpts"]),
}, },
created() { created() {
this.formInit = deepCopy(this.form);
this.formInit = deepCopy(this.form);
}, },
mounted() { mounted() {
// //
@ -143,7 +152,7 @@ export default {
// immediate: true, // immediate: true,
handler(newVal, oldVal) { handler(newVal, oldVal) {
console.log(`watch 体检分组 newVal:${newVal} oldVal:${oldVal} this.params.id: ${this.params.id}`); console.log(`watch 体检分组 newVal:${newVal} oldVal:${oldVal} this.params.id: ${this.params.id}`);
if(newVal != oldVal) this.getFormData(this.params.id);
if (newVal != oldVal) this.getFormData(this.params.id);
} }
}, },
}, },

3
src/components/commonTable/commonTableType.vue

@ -12,6 +12,7 @@
<el-table-column type="index" label="序号" width="50" align="center" /> <el-table-column type="index" label="序号" width="50" align="center" />
<el-table-column label="编号" prop="id" min-width="200" align="center" /> <el-table-column label="编号" prop="id" min-width="200" align="center" />
<el-table-column prop="displayName" label="分类名称" min-width="150" /> <el-table-column prop="displayName" label="分类名称" min-width="150" />
<el-table-column prop="columnName" label="多列名配置" min-width="300" show-overflow-tooltip/>
<el-table-column prop="creatorName" label="创建者" min-width="80" align="center" /> <el-table-column prop="creatorName" label="创建者" min-width="80" align="center" />
<el-table-column label="创建时间" min-width="150" align="center"> <el-table-column label="创建时间" min-width="150" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
@ -63,7 +64,7 @@
<!--分组项目信息 --> <!--分组项目信息 -->
<div> <div>
<CommonTable :commonTableType="curCommonTableType" />
<CommonTable :refParams="curCommonTableType" />
</div> </div>
</div> </div>

Loading…
Cancel
Save