|
@@ -0,0 +1,220 @@
|
|
|
+<template>
|
|
|
+ <div id="detail">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
|
|
|
+ <el-col :span="24" class="one">
|
|
|
+ <cSearch :is_title="false" :is_back="true" @toBack="toBack"></cSearch>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="two">
|
|
|
+ <cForm :fields="fields" :form="form" :rules="rules" @save="toSave">
|
|
|
+ <template #belong>
|
|
|
+ <el-option v-for="i in belongList" :key="i.value" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #image_file>
|
|
|
+ <cUpload
|
|
|
+ :model="`image_file`"
|
|
|
+ :limit="1"
|
|
|
+ url="/files/zkzx/subscribe/upload"
|
|
|
+ :list="form.image_file"
|
|
|
+ listType="picture-card"
|
|
|
+ @change="onUpload"
|
|
|
+ ></cUpload>
|
|
|
+ </template>
|
|
|
+ <template #is_use>
|
|
|
+ <el-option v-for="i in isuseList" :key="i.value" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #project>
|
|
|
+ <el-col :span="24" class="project">
|
|
|
+ <el-col :span="24" class="btn">
|
|
|
+ <el-button type="primary" @click="toAdd('project')">添加</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="list">
|
|
|
+ <cTable :fields="projectfields" :opera="otheropera" :list="form.project" :usePage="false" @edit="prEdit" @del="prDel"> </cTable>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </template>
|
|
|
+ <template #equipment>
|
|
|
+ <el-col :span="24" class="project">
|
|
|
+ <el-col :span="24" class="btn">
|
|
|
+ <el-button type="primary" @click="toAdd('equipment')">添加</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="list">
|
|
|
+ <cTable :fields="projectfields" :opera="otheropera" :list="form.equipment" :usePage="false" @edit="eqEdit" @del="eqDel"> </cTable>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </template>
|
|
|
+ </cForm>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <cDialog :dialog="dialog" @handleClose="toClose">
|
|
|
+ <template v-slot:info>
|
|
|
+ <el-col :span="24" class="dialog_type" v-if="dialog.type == '1'">
|
|
|
+ <cForm :fields="projectfields" :form="otherForm" :rules="{}" @save="otherSave"> </cForm>
|
|
|
+ </el-col>
|
|
|
+ </template>
|
|
|
+ </cDialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+// 基础
|
|
|
+import moment from 'moment';
|
|
|
+import type { Ref } from 'vue';
|
|
|
+import { ref, reactive, onMounted } from 'vue';
|
|
|
+import { useRoute } from 'vue-router';
|
|
|
+import { ElMessage } from 'element-plus';
|
|
|
+import type { FormRules } from 'element-plus';
|
|
|
+// 接口
|
|
|
+import { SubscribeOrganStore } from '@common/src/stores/admins/subscribeOrgan';
|
|
|
+import { DictDataStore } from '@common/src/stores/system/dictData'; // 字典表
|
|
|
+import type { IQueryResult } from '@/util/types.util';
|
|
|
+const orgaAxios = SubscribeOrganStore();
|
|
|
+const dictData = DictDataStore();
|
|
|
+
|
|
|
+// 路由
|
|
|
+const route = useRoute();
|
|
|
+
|
|
|
+// 加载中
|
|
|
+const loading: Ref<any> = ref(false);
|
|
|
+// 表单
|
|
|
+let form: Ref<any> = ref({});
|
|
|
+let fields: Ref<any[]> = ref([
|
|
|
+ { label: '名称', model: 'name' },
|
|
|
+ { label: '联系人', model: 'contact' },
|
|
|
+ { label: '手机号', model: 'phone' },
|
|
|
+ { label: '联系地址', model: 'address' },
|
|
|
+ { label: '所属', model: 'belong', type: 'select' },
|
|
|
+ { label: '资质', model: 'natural', type: 'textarea' },
|
|
|
+ { label: '成果', model: 'achieve', type: 'textarea' },
|
|
|
+ { label: '条件', model: 'condition', type: 'textarea' },
|
|
|
+ { label: '团队', model: 'team', type: 'textarea' },
|
|
|
+ { label: '图片', model: 'image_file', custom: true },
|
|
|
+ { label: '服务项目', model: 'project', custom: true },
|
|
|
+ { label: '设备共享', model: 'equipment', custom: true },
|
|
|
+ { label: '是否使用', model: 'is_use', type: 'select' }
|
|
|
+]);
|
|
|
+const rules = reactive<FormRules>({});
|
|
|
+// 服务项目,设备共享
|
|
|
+const projectfields: Ref<any> = ref([
|
|
|
+ { label: '名称', model: 'name' },
|
|
|
+ { label: '联系人', model: 'contact' },
|
|
|
+ { label: '手机号', model: 'phone' },
|
|
|
+ { label: '电子邮箱', model: 'email' },
|
|
|
+ { label: '邮编', model: 'post' },
|
|
|
+ { label: '服务内容', model: 'content', type: 'textarea' }
|
|
|
+]);
|
|
|
+const other_type: Ref<any> = ref('');
|
|
|
+// 字典表
|
|
|
+let isuseList: Ref<any> = ref([]);
|
|
|
+let belongList: Ref<any> = ref([]);
|
|
|
+// 弹框
|
|
|
+const dialog: Ref<any> = ref({ title: '信息管理', show: false, type: '1' });
|
|
|
+const otherForm: Ref<any> = ref({});
|
|
|
+const otheropera: Ref<any[]> = ref([
|
|
|
+ { label: '修改', method: 'edit' },
|
|
|
+ { label: '删除', method: 'del', confirm: true, type: 'danger' }
|
|
|
+]);
|
|
|
+
|
|
|
+// 请求
|
|
|
+onMounted(async () => {
|
|
|
+ loading.value = true;
|
|
|
+ await searchOther();
|
|
|
+ await search();
|
|
|
+ loading.value = false;
|
|
|
+});
|
|
|
+const search = async () => {
|
|
|
+ let id = route.query.id;
|
|
|
+ let object: any = {};
|
|
|
+ if (id) {
|
|
|
+ let res: IQueryResult = await orgaAxios.fetch(id);
|
|
|
+ if (res.errcode == 0) {
|
|
|
+ object.value = res.data as {};
|
|
|
+ }
|
|
|
+ }
|
|
|
+ form.value = object;
|
|
|
+};
|
|
|
+const onUpload = (e: { model: string; value: Array<[]> }) => {
|
|
|
+ const { model, value } = e;
|
|
|
+ form.value[model] = value;
|
|
|
+};
|
|
|
+// 添加
|
|
|
+const toAdd = (e) => {
|
|
|
+ other_type.value = e;
|
|
|
+ dialog.value = { title: '信息管理', show: true, type: '1' };
|
|
|
+};
|
|
|
+// 服务修改
|
|
|
+const prEdit = (data) => {
|
|
|
+ other_type.value = 'project';
|
|
|
+ otherForm.value = data;
|
|
|
+ dialog.value = { title: '信息管理', show: true, type: '1' };
|
|
|
+};
|
|
|
+// 服务删除
|
|
|
+const prDel = (data) => {
|
|
|
+ let list = form.value.project.filter((i) => i.id != data.id);
|
|
|
+ form.value.project = list;
|
|
|
+};
|
|
|
+// 设备修改
|
|
|
+const eqEdit = (data) => {
|
|
|
+ other_type.value = 'equipment';
|
|
|
+ otherForm.value = data;
|
|
|
+ dialog.value = { title: '信息管理', show: true, type: '1' };
|
|
|
+};
|
|
|
+// 设备删除
|
|
|
+const eqDel = (data) => {
|
|
|
+ let list = form.value.equipment.filter((i) => i.id != data.id);
|
|
|
+ form.value.equipment = list;
|
|
|
+};
|
|
|
+// 提交保存
|
|
|
+const otherSave = (data) => {
|
|
|
+ if (other_type.value == 'project') {
|
|
|
+ if (!data.id) {
|
|
|
+ data.id = moment().valueOf();
|
|
|
+ let project = form.value.project || [];
|
|
|
+ project = [...project, data];
|
|
|
+ form.value.project = project;
|
|
|
+ }
|
|
|
+ } else if (other_type.value == 'equipment') {
|
|
|
+ if (!data.id) {
|
|
|
+ data.id = moment().valueOf();
|
|
|
+ let equipment = form.value.equipment || [];
|
|
|
+ equipment = [...equipment, data];
|
|
|
+ form.value.equipment = equipment;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ toClose();
|
|
|
+};
|
|
|
+
|
|
|
+// 关闭弹框
|
|
|
+const toClose = () => {
|
|
|
+ otherForm.value = {};
|
|
|
+ dialog.value = { title: '信息管理', show: false, type: '1' };
|
|
|
+};
|
|
|
+// 提交
|
|
|
+const toSave = async (data) => {
|
|
|
+ let res: IQueryResult;
|
|
|
+ if (data._id) res = await orgaAxios.update(data);
|
|
|
+ else res = await orgaAxios.create(data);
|
|
|
+ if (res.errcode == 0) {
|
|
|
+ ElMessage({ type: `success`, message: `维护信息成功` });
|
|
|
+ toBack();
|
|
|
+ }
|
|
|
+};
|
|
|
+const searchOther = async () => {
|
|
|
+ let res: IQueryResult;
|
|
|
+ // 是否使用
|
|
|
+ res = await dictData.query({ type: 'common_use' });
|
|
|
+ if (res.errcode == 0) isuseList.value = res.data;
|
|
|
+};
|
|
|
+// 返回上一页
|
|
|
+const toBack = () => {
|
|
|
+ window.history.go(-1);
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style scoped lang="scss">
|
|
|
+.project {
|
|
|
+ .btn {
|
|
|
+ margin: 0 0 10px 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|