unit-1.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <div id="unit-1">
  3. <el-row>
  4. <el-col :span="24" class="main">
  5. <el-col :span="24" class="one">
  6. <el-col :span="24" class="one_1">一、账户信息</el-col>
  7. <el-col :span="24" class="one_2">
  8. <component :is="CForm" :fields="fields" :rules="{}" :form="form" labelWidth="auto" @save="toSave">
  9. <template #is_studio>
  10. <el-option v-for="item in studioList" :key="item.dict_label" :label="item.dict_label" :value="item.dict_value"></el-option>
  11. </template>
  12. <template #prove>
  13. <component style="width: 100%" :is="CFile" model="prove" :limit="limit" :url="url" :list="form.prove" @change="onChange"></component>
  14. </template>
  15. </component>
  16. </el-col>
  17. </el-col>
  18. <el-col :span="24" class="two" v-show="form.is_studio == 'Y'">
  19. <el-col :span="24" class="two_1">二、基础信息</el-col>
  20. <el-col :span="24" class="two_2">
  21. <component :is="CForm" :fields="ufields" :rules="rules" :form="uform" labelWidth="auto" @save="utoSave" @dataChange="dataChange">
  22. <template #card>
  23. <component
  24. style="width: 100%"
  25. :is="CFile"
  26. model="card"
  27. limit="2"
  28. url="/files/studioadmin/register/upload"
  29. :list="uform.card"
  30. @change="uonChange"
  31. ></component>
  32. </template>
  33. <template #unit_phone>
  34. <el-col :span="12">
  35. <el-form-item label="内容" label-width="100px" prop="unit_phone.phone">
  36. <el-input v-model="uform.unit_phone.phone" :disabled="true" placeholder="请输入联系电话"></el-input>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="12">
  40. <el-form-item label="是否公开" label-width="80px">
  41. <el-select v-model="uform.unit_phone.is_show" placeholder="请选择" style="width: 100%">
  42. <el-option v-for="i in isshowList" :key="i.model" :label="i.dict_label" :value="i.dict_value"></el-option>
  43. </el-select>
  44. </el-form-item>
  45. </el-col>
  46. </template>
  47. <template #unit_email>
  48. <el-col :span="12">
  49. <el-form-item label="内容" label-width="100px" prop="unit_email.email">
  50. <el-input v-model="uform.unit_email.email" :disabled="true" placeholder="请输入单位联系电话"></el-input>
  51. </el-form-item>
  52. </el-col>
  53. <el-col :span="12">
  54. <el-form-item label="是否公开" label-width="80px">
  55. <el-select v-model="uform.unit_email.is_show" placeholder="请选择" style="width: 100%">
  56. <el-option v-for="i in isshowList" :key="i.model" :label="i.dict_label" :value="i.dict_value"></el-option>
  57. </el-select>
  58. </el-form-item>
  59. </el-col>
  60. </template>
  61. <template #fields>
  62. <el-option v-for="i in fieldList" :key="i.dict_value" :label="i.dict_label" :value="i.dict_value"></el-option>
  63. </template>
  64. <template #direction>
  65. <el-button style="margin-bottom: 0.5vw" type="primary" size="small" @click="addDriection()">添加</el-button>
  66. <el-col :span="24">
  67. <el-table :data="uform.direction" border size="small">
  68. <el-table-column type="index" label="序号" width="50" align="center"> </el-table-column>
  69. <el-table-column prop="name" label="名称" align="center">
  70. <template v-slot="scope">
  71. <el-input v-model="scope.row.name" placeholder="请输入技术需求方向名称,名称长度不可超过八个字" maxlength="8"></el-input>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="操作" align="center" width="100">
  75. <template v-slot="scope">
  76. <el-button size="small" type="danger" @click="delDriection(scope.row)">删除</el-button>
  77. </template>
  78. </el-table-column>
  79. </el-table>
  80. </el-col>
  81. </template>
  82. <template #audit_report>
  83. <component
  84. style="width: 100%"
  85. :is="CFile"
  86. model="audit_report"
  87. :limit="limit"
  88. :url="url"
  89. :list="uform.audit_report"
  90. @change="uonChange"
  91. ></component>
  92. </template>
  93. <template #special_report>
  94. <component
  95. style="width: 100%"
  96. :is="CFile"
  97. model="special_report"
  98. :limit="limit"
  99. :url="url"
  100. :list="uform.special_report"
  101. @change="uonChange"
  102. ></component>
  103. </template>
  104. <template #prove_file>
  105. <component
  106. style="width: 100%"
  107. :is="CFile"
  108. model="prove_file"
  109. :limit="limit"
  110. :url="url"
  111. :list="uform.prove_file"
  112. @change="uonChange"
  113. ></component>
  114. </template>
  115. </component>
  116. </el-col>
  117. </el-col>
  118. </el-col>
  119. </el-row>
  120. </div>
  121. </template>
  122. <script setup lang="ts">
  123. import store from '@/stores/counter';
  124. import moment from 'moment';
  125. // #region 组件
  126. import CForm from '@common/src/components/frame/c-form.vue';
  127. import CFile from '@common/src/components/frame/c-upload.vue';
  128. // #endregion
  129. import type { Ref } from 'vue';
  130. import { ref, onMounted, reactive, watch } from 'vue';
  131. import type { FormRules } from 'element-plus';
  132. import { ElMessage } from 'element-plus';
  133. // #region 接口
  134. import { UnitStore } from '@common/src/stores/users/unit'; //依托单位
  135. import { UnitStudioApplyStore } from '@common/src/stores/studio/role/unitStudioApply'; // 依托单位申请科学家工作室权限表
  136. import { DictDataStore } from '@common/src/stores/users/sysdictdata'; // 字典表
  137. import type { IQueryResult } from '@/util/types.util';
  138. const unitStudioApply = UnitStudioApplyStore();
  139. const unit = UnitStore();
  140. const sysdictdata = DictDataStore();
  141. // 必填项
  142. const rules = reactive<FormRules>({
  143. company: [{ required: true, message: '请输入单位全称', trigger: 'blur' }],
  144. address: [{ required: true, message: '请输入单位地址', trigger: 'blur' }],
  145. name: [{ required: true, message: '请输入单位法人姓名', trigger: 'blur' }],
  146. phone: [
  147. { required: true, message: '单位法人手机号码', trigger: 'change' },
  148. { pattern: /^1[3|5|7|8|9]\d{9}$/, message: '请输入正确的号码格式', trigger: 'change' },
  149. ],
  150. card: [{ required: true, message: '请上传法人身份证', trigger: 'change' }],
  151. unit_contact: [{ required: true, message: '请输入单位联系人', trigger: 'blur' }],
  152. 'unit_phone.phone': [
  153. { required: true, message: '单位联系电话', trigger: 'change' },
  154. { pattern: /^1[3|5|7|8|9]\d{9}$/, message: '请输入正确的号码格式', trigger: 'change' },
  155. ],
  156. 'unit_email.email': [{ required: true, message: '请输入单位电子邮箱', trigger: 'blur' }],
  157. fields: [{ required: true, message: '请选择行业领域', trigger: 'change' }],
  158. direction: [{ required: true, message: '请添加技术需求方向', trigger: 'change' }],
  159. audit_report: [{ required: true, message: '请上传上一年度财务审计报告', trigger: 'change' }],
  160. special_report: [{ required: true, message: '请上传上一年度R&D投入专项', trigger: 'change' }],
  161. prove_file: [{ required: false, message: '请上传其他证明资料', trigger: 'change' }],
  162. });
  163. // 系统表单
  164. let fields: Ref<any[]> = ref([
  165. { label: '登录账号', model: 'account', options: { readonly: true } },
  166. { label: '管理员姓名', model: 'name' },
  167. { label: '管理员手机号', model: 'phone' },
  168. { label: '管理员电子邮箱', model: 'email' },
  169. { label: '单位全称', model: 'unit_name' },
  170. { label: '单位地址', model: 'unit_address' },
  171. { label: '营业执照', model: 'prove', custom: true },
  172. { label: '是否入住科学家工作室', model: 'is_studio', type: 'select' },
  173. ]);
  174. // 依托单位信息表单
  175. let ufields: Ref<any[]> = ref([
  176. { label: '单位全称', model: 'company', options: { readonly: true } },
  177. { label: '单位地址', model: 'address', options: { readonly: true } },
  178. { label: '单位法人姓名', model: 'name' },
  179. { label: '单位法人手机号码', model: 'phone' },
  180. { label: '法人身份证', model: 'card', custom: true },
  181. { label: '单位联系人', model: 'unit_contact', options: { readonly: true } },
  182. { label: '单位手机号', model: 'unit_phone', custom: true },
  183. { label: '单位电子邮箱', model: 'unit_email', custom: true },
  184. { label: '行业领域(2)', model: 'fields', type: 'selectMany', options: { placeholder: '请选择(多选,不超过2个)' } },
  185. { label: '技术需求方向', model: 'direction', custom: true },
  186. { label: '上一年度财务审计报告', model: 'audit_report', custom: true },
  187. { label: '上一年度R&D投入专项', model: 'special_report', custom: true },
  188. { label: '其他证明资料', model: 'prove_file', custom: true },
  189. ]);
  190. let limit: Ref<number> = ref(1);
  191. let url: Ref<string> = ref('/files/jcyjdt/unit/upload');
  192. // 用户信息
  193. let user: Ref<{ _id: string; name: string; unit_name: string; account: string; unit_address: string; email: string }> = ref({
  194. _id: '',
  195. name: '',
  196. unit_name: '',
  197. account: '',
  198. unit_address: '',
  199. email: '',
  200. });
  201. // 表单
  202. let form: Ref<{ is_studio: string; prove: Array<[]>; direction: Array<[]> }> = ref({ is_studio: '', prove: [], direction: [] });
  203. let uform: Ref<{
  204. _id: string;
  205. card: Array<any>;
  206. unit_phone: { phone: string; is_show: string };
  207. unit_email: { email: string; is_show: string };
  208. fields: Array<any>;
  209. direction: Array<any>;
  210. audit_report: Array<any>;
  211. special_report: Array<any>;
  212. prove_file: Array<any>;
  213. company: string;
  214. unit_id: string;
  215. unit_contact: string;
  216. address: string;
  217. }> = ref({
  218. _id: '',
  219. card: [],
  220. unit_phone: { phone: '', is_show: '' },
  221. unit_email: { email: '', is_show: '' },
  222. company: '',
  223. unit_id: '',
  224. unit_contact: '',
  225. address: '',
  226. fields: [],
  227. direction: [],
  228. audit_report: [],
  229. special_report: [],
  230. prove_file: [],
  231. });
  232. // 行业领域
  233. let fieldList: Ref<any[]> = ref([]);
  234. // 是否显示
  235. let isshowList: Ref<any[]> = ref([]);
  236. // 工作室
  237. let studioList: Ref<any[]> = ref([]);
  238. // 状态
  239. let statusList: Ref<any[]> = ref([]);
  240. onMounted(async () => {
  241. user.value = store.state.user as { _id: string; name: string; unit_name: string; account: string; unit_address: string; email: string };
  242. await searchOther();
  243. await searchBasic();
  244. await search();
  245. });
  246. // 基本信息查询
  247. const searchBasic = async () => {
  248. let res: IQueryResult = await unit.fetch(user.value._id);
  249. if (res.errcode == 0) {
  250. if (res.data) {
  251. form.value = res.data as { is_studio: ''; prove: []; direction: [] };
  252. }
  253. }
  254. };
  255. // 查询
  256. const search = async () => {
  257. // 查询已申请数据状态
  258. let res: IQueryResult = await unitStudioApply.query({ unit_id: user.value._id });
  259. if (res.errcode == 0) {
  260. if (res.total > 0) {
  261. uform.value = res.data[0] as {
  262. _id: '';
  263. card: [];
  264. unit_phone: { phone: ''; is_show: '' };
  265. unit_email: { email: ''; is_show: '' };
  266. company: '';
  267. unit_id: '';
  268. unit_contact: '';
  269. address: '';
  270. fields: [];
  271. direction: [];
  272. audit_report: [];
  273. special_report: [];
  274. prove_file: [];
  275. };
  276. } else {
  277. if (user && user.value._id) {
  278. uform.value.unit_id = user.value._id;
  279. uform.value.company = user.value.unit_name || '';
  280. uform.value.address = user.value.unit_address || '';
  281. uform.value.unit_contact = user.value.name || '';
  282. uform.value.unit_email = { email: user.value.email || '', is_show: '' };
  283. }
  284. }
  285. }
  286. };
  287. // 改变基础信息关联
  288. const changeForm = (val: { name: string; phone: string; email: string; unit_name: string; unit_address: string }) => {
  289. uform.value.unit_contact = val.name;
  290. uform.value.unit_phone.phone = val.phone;
  291. uform.value.unit_email.email = val.email;
  292. uform.value.company = val.unit_name;
  293. uform.value.address = val.unit_address;
  294. };
  295. // 研究方向添加
  296. const addDriection = () => {
  297. let direction: any = form.value.direction;
  298. if (direction.length >= 5) {
  299. ElMessage({ message: `研究方向最多添加五个`, type: 'error' });
  300. } else {
  301. direction.push({ id: moment().valueOf(), name: '' });
  302. }
  303. form.value.direction = direction;
  304. };
  305. // 研究方向删除
  306. const delDriection = (e: { id: '' }) => {
  307. let direction = form.value.direction.filter((i: any) => i.id != e.id);
  308. form.value.direction = direction;
  309. };
  310. // 依托单位添加
  311. const utoSave = async (data: any) => {
  312. let res: IQueryResult;
  313. if (data.status == '2') data.status = '0';
  314. if (data._id) res = await unitStudioApply.update(data);
  315. else {
  316. res = await unitStudioApply.update(data);
  317. // 入住科学工作室 修改unit表中的is_studio
  318. updateBasic();
  319. }
  320. if (res.errcode == 0) {
  321. ElMessage({ message: `维护信息成功`, type: 'success' });
  322. search();
  323. }
  324. };
  325. // 修改基础信息
  326. const updateBasic = async () => {
  327. let res: IQueryResult = await unit.update({ _id: user.value._id, is_studio: 'Y', account: user.value.account });
  328. console.log(res);
  329. };
  330. // 监听数据
  331. const dataChange = (model: string, value: Array<[]>) => {
  332. if (model == 'fields') {
  333. if (value.length > 2) {
  334. ElMessage({ message: `数据过多,请重新选择`, type: 'error' });
  335. }
  336. }
  337. };
  338. // 基础信息上传
  339. const onChange = (e: { model: string; value: Array<[]> }) => {
  340. const { model, value } = e;
  341. form.value[model] = value;
  342. };
  343. // 依托单位上传
  344. const uonChange = (e: { model: string; value: Array<[]> }) => {
  345. const { model, value } = e;
  346. uform.value[model] = value;
  347. };
  348. // 添加
  349. const toSave = async (data: any) => {
  350. let res: IQueryResult = await unit.update(data);
  351. if (res.errcode == 0) {
  352. // ElMessage({ type: 'success', message: '维护信息成功' });
  353. // 同步修改依托单位信息
  354. let form = {
  355. _id: uform.value._id,
  356. unit_contact: data.name,
  357. unit_phone: { phone: data.phone },
  358. unit_email: { email: data.email },
  359. company: data.unit_name,
  360. address: data.unit_address,
  361. };
  362. await utoSave(form);
  363. await search();
  364. } else ElMessage({ type: 'warning', message: `${res.errmsg}` });
  365. };
  366. // 查询其他信息
  367. const searchOther = async () => {
  368. let res: IQueryResult;
  369. //是否公开
  370. res = await sysdictdata.query({ dict_type: 's_is_show' });
  371. if (res.errcode == '0') isshowList.value = res.data as [];
  372. // 领域
  373. res = await sysdictdata.query({ dict_type: 'studio_field' });
  374. if (res.errcode == '0') fieldList.value = res.data as [];
  375. // 是否入住科学家工作室
  376. res = await sysdictdata.query({ dict_type: 'sys_yes_no' });
  377. if (res.errcode == '0') studioList.value = res.data as [];
  378. // 审核状态
  379. res = await sysdictdata.query({ dict_type: 'studio_status' });
  380. if (res.errcode == '0') statusList.value = res.data as [];
  381. };
  382. watch(
  383. form,
  384. (newVal: any) => {
  385. if (newVal && newVal._id) {
  386. changeForm(newVal);
  387. }
  388. },
  389. {
  390. deep: true,
  391. }
  392. );
  393. </script>
  394. <style lang="scss" scoped>
  395. .main {
  396. .one {
  397. .one_1 {
  398. font-size: 22px;
  399. margin: 10px 0;
  400. }
  401. }
  402. .two {
  403. .two_1 {
  404. font-size: 22px;
  405. margin: 10px 0;
  406. }
  407. }
  408. }
  409. </style>