SourceDetail.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. <!--
  2. * @Author: tengmingxue 1473375109@qq.com
  3. * @Date: 2023-08-15 22:08:21
  4. * @LastEditors: tengmingxue 1473375109@qq.com
  5. * @LastEditTime: 2023-08-17 15:24:30
  6. * @FilePath: \xld-gis-admin\src\views\resource\map\SourceDetail.vue
  7. * @Description: 地图资源明细界面
  8. -->
  9. <template>
  10. <div class="source-detail">
  11. <a-form ref="formRef" :model="formState" :rules="rules" style="width: 100%">
  12. <div class="compontents">
  13. <div class="title">基本信息</div>
  14. <a-row class="form-container">
  15. <a-col :span="12" class="form-col">
  16. <a-form-item ref="code" label="资源编码" name="code" class="label-form-item">
  17. <a-input v-model:value="formState.code" />
  18. </a-form-item>
  19. </a-col>
  20. <a-col :span="12" class="form-col">
  21. <a-form-item
  22. ref="servicename"
  23. label="资源名称"
  24. name="servicename"
  25. class="label-form-item"
  26. >
  27. <a-input v-model:value="formState.servicename" />
  28. </a-form-item>
  29. </a-col>
  30. <a-col :span="12" class="form-col">
  31. <a-form-item
  32. ref="servicealiasname"
  33. label="资源别名"
  34. name="servicealiasname"
  35. class="label-form-item"
  36. >
  37. <a-input v-model:value="formState.servicealiasname" />
  38. </a-form-item>
  39. </a-col>
  40. <a-col :span="12" class="form-col">
  41. <a-form-item ref="keywords" label="资源标签" name="keywords" class="label-form-item">
  42. <a-select v-model:value="formState.keywords" mode="multiple">
  43. <template v-for="tag in serviceTags" :key="tag.code">
  44. <a-select-option :value="tag.value">{{ tag.label }}</a-select-option>
  45. </template>
  46. </a-select>
  47. </a-form-item>
  48. </a-col>
  49. <a-col :span="24" class="form-col">
  50. <a-form-item
  51. ref="description"
  52. label="资源描述"
  53. name="description"
  54. class="label-form-item"
  55. >
  56. <a-textarea v-model:value="formState.description" :rows="2" />
  57. </a-form-item>
  58. </a-col>
  59. <a-col :span="24" class="form-col">
  60. <a-form-item ref="thumbnail" label="缩略图" name="thumbnail" class="label-form-item">
  61. <a-upload action="" v-model:file-list="fileList">
  62. <a-button style="background-color: #0671dd; color: #fff; border-radius: 4px">
  63. <upload-outlined></upload-outlined>
  64. 文件上传
  65. </a-button>
  66. </a-upload>
  67. </a-form-item>
  68. </a-col>
  69. </a-row>
  70. </div>
  71. <div class="compontents">
  72. <div class="title">描述信息</div>
  73. <a-row class="form-container">
  74. <a-col :span="12" class="form-col">
  75. <a-form-item
  76. ref="servicetype"
  77. label="资源类型"
  78. name="servicetype"
  79. class="label-form-item"
  80. >
  81. <a-select v-model:value="formState.servicetype">
  82. <template v-for="tag in serviceTypes" :key="tag.id">
  83. <a-select-option :value="tag.id">{{ tag.name }}</a-select-option>
  84. </template>
  85. </a-select>
  86. </a-form-item>
  87. </a-col>
  88. <a-col :span="12" class="form-col">
  89. <a-form-item ref="coordinate" label="坐标系" name="coordinate" class="label-form-item">
  90. <a-select v-model:value="formState.coordinate">
  91. <template v-for="tag in sysCoors" :key="tag.GEOMNAME">
  92. <a-select-option :value="tag.GEOMNAME">{{ tag.GEOMTITLE }}</a-select-option>
  93. </template>
  94. </a-select>
  95. </a-form-item>
  96. </a-col>
  97. <a-col :span="24" class="form-col">
  98. <a-form-item ref="mapingurl" label="服务地址" name="mapingurl" class="label-form-item">
  99. <a-input v-model:value="formState.mapingurl" />
  100. </a-form-item>
  101. </a-col>
  102. <a-col :span="12" class="form-col">
  103. <a-form-item ref="dataScope" label="数据范围" name="dataScope" class="label-form-item">
  104. <a-input v-model:value="formState.dataScope" />
  105. </a-form-item>
  106. </a-col>
  107. <a-col :span="12" class="form-col">
  108. <a-form-item ref="source" label="数据来源" name="source" class="label-form-item">
  109. <a-input v-model:value="formState.source" />
  110. </a-form-item>
  111. </a-col>
  112. <a-col :span="12" class="form-col">
  113. <a-form-item ref="restype" label="密级" name="secrets" class="label-form-item">
  114. <a-select v-model:value="formState.secrets">
  115. <template v-for="tag in secrets" :key="tag.code">
  116. <a-select-option :value="tag.code">{{ tag.name }}</a-select-option>
  117. </template>
  118. </a-select>
  119. </a-form-item>
  120. </a-col>
  121. <a-col :span="12" class="form-col">
  122. <a-form-item
  123. ref="sourcetable"
  124. label="数据表"
  125. name="sourcetable"
  126. class="label-form-item"
  127. >
  128. <a-input v-model:value="formState.formdatabase" />
  129. </a-form-item>
  130. </a-col>
  131. <a-col :span="12" class="form-col">
  132. <a-form-item ref="collect" label="保管单位" name="collect" class="label-form-item">
  133. <a-select v-model:value="formState.collect">
  134. <template v-for="tag in collectDept" :key="tag.code">
  135. <a-select-option :value="tag.code">{{ tag.name }}</a-select-option>
  136. </template>
  137. </a-select>
  138. </a-form-item>
  139. </a-col>
  140. <a-col :span="12" class="form-col">
  141. <a-form-item ref="respUnit" label="责任处室" name="respUnit" class="label-form-item">
  142. <a-select v-model:value="formState.respUnit">
  143. <template v-for="tag in respDept" :key="tag.code">
  144. <a-select-option :value="tag.code">{{ tag.name }}</a-select-option>
  145. </template>
  146. </a-select>
  147. </a-form-item>
  148. </a-col>
  149. <a-col :span="12" class="form-col">
  150. <a-form-item ref="source" label="发布日期" name="source" class="label-form-item">
  151. <!-- <a-input v-model:value="formState.publishtime" disabled /> -->
  152. <a-date-picker
  153. v-model:value="formState.publishtime"
  154. format="YYYY-MM-DD hh:mm:ss"
  155. style="width: 100%"
  156. disabled
  157. show-time
  158. >
  159. <template #renderExtraFooter>extra footer</template>
  160. </a-date-picker>
  161. </a-form-item>
  162. </a-col>
  163. <a-col :span="12" class="form-col">
  164. <a-form-item ref="source" label="发布者" name="source" class="label-form-item">
  165. <a-input v-model:value="formState.publisher" disabled />
  166. </a-form-item>
  167. </a-col>
  168. <a-col :span="12" class="form-col">
  169. <a-form-item
  170. ref="updatetype"
  171. label="更新方式"
  172. name="updatetype"
  173. class="label-form-item"
  174. >
  175. <a-input v-model:value="formState.updateType" />
  176. </a-form-item>
  177. </a-col>
  178. <a-col :span="12" class="form-col">
  179. <a-form-item
  180. ref="updatetime"
  181. label="更新时间"
  182. name="updatetime"
  183. class="label-form-item"
  184. >
  185. <a-date-picker
  186. v-model:value="formState.updatetime"
  187. format="YYYY-MM-DD hh:mm:ss"
  188. style="width: 100%"
  189. disabled
  190. show-time
  191. >
  192. <template #renderExtraFooter>extra footer</template>
  193. </a-date-picker>
  194. </a-form-item>
  195. </a-col>
  196. <a-col :span="12" class="form-col">
  197. <a-form-item ref="epsgcode" label="EPSGCode" name="epsgcode" class="label-form-item">
  198. <a-select v-model:value="formState.epsgcode">
  199. <template v-for="tag in EPSGCodes" :key="tag.code">
  200. <a-select-option :value="tag.code">{{ tag.name }}</a-select-option>
  201. </template>
  202. </a-select>
  203. </a-form-item>
  204. </a-col>
  205. <a-col :span="12" class="form-col">
  206. <a-form-item
  207. ref="runtimestatus"
  208. label="运行状态"
  209. name="runtimestatus"
  210. class="label-form-item"
  211. >
  212. <a-switch
  213. checked-children=""
  214. un-checked-children=""
  215. v-model:checked="formState.runtimestatus"
  216. />
  217. </a-form-item>
  218. </a-col>
  219. <a-col :span="6" class="form-col">
  220. <a-form-item ref="public" label="是否公开" name="public" class="label-form-item">
  221. <a-switch
  222. checked-children=""
  223. un-checked-children=""
  224. v-model:checked="formState.public"
  225. />
  226. </a-form-item>
  227. </a-col>
  228. <a-col :span="6" class="form-col">
  229. <a-form-item ref="share" label="是否共享" name="share" class="label-form-item">
  230. <a-switch
  231. checked-children=""
  232. un-checked-children=""
  233. v-model:checked="formState.share"
  234. />
  235. </a-form-item>
  236. </a-col>
  237. <a-col :span="6" class="form-col">
  238. <a-form-item
  239. ref="externalApply"
  240. label="是否外部申请"
  241. name="externalApply"
  242. class="label-form-item"
  243. >
  244. <a-switch
  245. checked-children=""
  246. un-checked-children=""
  247. v-model:checked="formState.externalApply"
  248. />
  249. </a-form-item>
  250. </a-col>
  251. <a-col :span="6" class="form-col">
  252. <a-form-item ref="searched" label="是否展示" name="searched" class="label-form-item">
  253. <a-switch
  254. checked-children=""
  255. un-checked-children=""
  256. v-model:checked="formState.searched"
  257. />
  258. </a-form-item>
  259. </a-col>
  260. </a-row>
  261. </div>
  262. </a-form>
  263. </div>
  264. </template>
  265. <script lang="ts">
  266. import {
  267. defineComponent,
  268. ref,
  269. toRefs,
  270. toRaw,
  271. unref,
  272. computed,
  273. unref,
  274. nextTick,
  275. reactive,
  276. UnwrapRef,
  277. onMounted,
  278. watch,
  279. } from 'vue';
  280. import { BasicForm, useForm } from '/@/components/Form/index';
  281. import { UploadOutlined } from '@ant-design/icons-vue';
  282. import { ValidateErrorEntity } from 'ant-design-vue/es/form/interface';
  283. import { useMessage } from '/@/hooks/web/useMessage';
  284. const { t } = useI18n(); //加载国际化
  285. // 加载菜单数据
  286. import { useI18n } from '/@/hooks/web/useI18n';
  287. import Moment from 'moment';
  288. import { insertService } from '/@/api/resource/map';
  289. import {
  290. serviceTypes,
  291. serviceTags,
  292. secrets,
  293. sysCoors,
  294. respDept,
  295. collectDept,
  296. EPSGCodes,
  297. } from './map.data';
  298. import { session } from '/@/utils/Memory.js';
  299. const props = {
  300. formData: { type: Object, default: ref(null) },
  301. isUpdate: { type: Boolean, default: ref(false) },
  302. };
  303. interface FormState {
  304. code: string;
  305. servicename: string;
  306. servicealiasname: string;
  307. keywords: string[];
  308. description: string;
  309. servicetype: string;
  310. coordinate: string;
  311. mapingurl: string;
  312. dataScope: string;
  313. source: string;
  314. secrets: string;
  315. formdatabase: string;
  316. collect: string;
  317. respUnit: string;
  318. publishtime: string;
  319. publisher: string;
  320. updateType: string;
  321. updatetime: string;
  322. epsgcode: string;
  323. runtimestatus: boolean;
  324. public: boolean;
  325. share: boolean;
  326. searched: boolean;
  327. externalApply: boolean;
  328. date1: undefined;
  329. }
  330. export default defineComponent({
  331. name: 'SourceDetail',
  332. components: { BasicForm, UploadOutlined },
  333. props,
  334. setup(props, { emit }) {
  335. const data = reactive({
  336. detail: props.formData,
  337. isUpdate: props.isUpdate,
  338. fileList: [],
  339. serviceTags: serviceTags,
  340. secrets: secrets, //密级
  341. sysCoors: sysCoors, //坐标系
  342. serviceTypes: serviceTypes, //资源类型
  343. respDept: respDept, //责任科室
  344. collectDept: collectDept, //保管部门
  345. EPSGCodes: EPSGCodes, //EPSGCode
  346. });
  347. const formRef = ref();
  348. const formState: UnwrapRef<FormState> = reactive({
  349. code: '',
  350. servicename: '',
  351. servicealiasname: '',
  352. keywords: [],
  353. description: '',
  354. servicetype: '',
  355. coordinate: '',
  356. mapingurl: '',
  357. dataScope: '',
  358. source: '',
  359. secrets: '',
  360. formdatabase: '',
  361. collect: '',
  362. respUnit: '',
  363. publishtime: '',
  364. publisher: '',
  365. updateType: '',
  366. updatetime: '',
  367. epsgcode: '',
  368. runtimestatus: true,
  369. public: true,
  370. share: true,
  371. searched: true,
  372. externalApply: true,
  373. date1: undefined,
  374. });
  375. const moment = Moment;
  376. const rules = {
  377. servicename: [
  378. { required: true, message: '请填写资源名称', trigger: 'blur' },
  379. { min: 3, max: 20, message: '长度必须在3到20个字符', trigger: 'blur' },
  380. ],
  381. servicealiasname: [
  382. { required: true, message: '请输入资源别名', trigger: 'blur' },
  383. { min: 3, max: 20, message: '长度必须在3到20个字符', trigger: 'blur' },
  384. ],
  385. systag: [{ required: true, message: '请选择系统标签', trigger: 'change' }],
  386. servicetype: [{ required: true, message: '请选择资源类型', trigger: 'change' }],
  387. coordinate: [{ required: true, message: '请选择坐标系', trigger: 'change' }],
  388. mapingurl: [{ required: true, message: '请输入服务地址', trigger: 'blur' }],
  389. date1: [{ required: true, message: 'Please pick a date', trigger: 'change', type: 'object' }],
  390. type: [
  391. {
  392. type: 'array',
  393. required: true,
  394. message: 'Please select at least one activity type',
  395. trigger: 'change',
  396. },
  397. ],
  398. resource: [{ required: true, message: 'Please select activity resource', trigger: 'change' }],
  399. desc: [{ required: true, message: 'Please input activity form', trigger: 'blur' }],
  400. };
  401. const { createMessage } = useMessage();
  402. watch(
  403. () => props.formData,
  404. (obj) => {
  405. data.detail = obj;
  406. if (data.isUpdate) setFormData();
  407. }
  408. );
  409. watch(
  410. () => props.isUpdate,
  411. (obj) => {
  412. data.isUpdate = obj;
  413. }
  414. );
  415. const submitForm = () => {
  416. try {
  417. formRef.value
  418. .validate()
  419. .then(async () => {
  420. //console.log('values', formState, toRaw(formState));
  421. const params = setSubmitForm();
  422. if (params) {
  423. if (data.isUpdate) {
  424. } else {
  425. const res = await insertService(params);
  426. if (res && res?.status !== '-1') {
  427. createMessage.success('新增地图资源成功!');
  428. resetForm();
  429. emit('RtnMain', true);
  430. } else createMessage.error('新增地图资源失败!,失败原因:' + res?.message, 1);
  431. }
  432. }
  433. })
  434. .catch((error: ValidateErrorEntity<FormState>) => {
  435. createMessage.error('请完成必填信息!', 1);
  436. console.log('error', error);
  437. });
  438. } catch (ex) {
  439. console.log(ex);
  440. }
  441. };
  442. const resetForm = () => {
  443. formRef.value.resetFields();
  444. };
  445. /**
  446. * 设置提交数据
  447. */
  448. const setSubmitForm = () => {
  449. const userinfo = session.getItem('userInfo');
  450. const collect = collectDept.find((item) => item.code === formState.collect);
  451. const rboffices = respDept.find((item) => item.code === formState.respUnit);
  452. const secretlevels = secrets.find((item) => item.code === formState.secrets);
  453. const coor = sysCoors.find((item) => item.GEOMNAME === formState.coordinate);
  454. const EPSGCode = EPSGCodes.find((item) => item.code === formState.epsgcode);
  455. return {
  456. type: 'MR',
  457. servicebase: {
  458. publisher: userinfo?.EMPLOYEE?.NAME, //'系统管理员',
  459. username: userinfo?.EMPLOYEE?.NAME, //'系统管理员',
  460. userid: userinfo?.EMPLOYEE?.EMPLOYEE_ID, //'27AF004A-8BDN-885T-30FU-89DE3388762B',
  461. servicealiasname: formState.servicealiasname, //资源别名
  462. description: formState.description, //资源描述
  463. ispublic: formState.public ? '1' : '0', //是否公开
  464. searched: formState.searched ? '1' : '0', //是否展示
  465. servicetype: formState.servicetype, //资源类型
  466. externalApply: formState.externalApply ? '1' : '0', //外部申请
  467. runtimestatus: formState.runtimestatus ? '1' : '0', //运行状态
  468. servicename: formState.servicename, //资源名
  469. mapingurl: formState.mapingurl, //服务地址
  470. otherService: '',
  471. },
  472. metadata: {
  473. mapingurl: formState.mapingurl, //服务地址
  474. name: formState.servicename, //资源名
  475. servicealiasname: formState.servicealiasname, //资源别名
  476. thumbnail: '',
  477. description: formState.description,
  478. keywords: formState.keywords.toString(),
  479. servicetype: formState.servicetype, //资源类型
  480. dataScope: formState.dataScope, //数据范围
  481. updateType: formState.updateType, //更新方式
  482. source: formState.source, //数据来源
  483. formdatabase: formState.formdatabase, //数据表
  484. rboffice: rboffices ? rboffices.codeName : '', //责任单位
  485. keepingunit: collect ? collect.codeName : '', //保管单位
  486. secretlevel: secretlevels ? secretlevels.codeName : '',
  487. crs: coor ? coor.GEOMNAME : '',
  488. epsgCode: EPSGCode ? EPSGCode.codeName : '',
  489. workSpace: '',
  490. runtimestatus: formState.runtimestatus ? '1' : '0', //运行状态
  491. ishistory: '0',
  492. shsqlc: 'ggdata',
  493. urlInfo: '',
  494. otherService: '',
  495. bz: '',
  496. ispublic: formState.public ? '1' : '0', //是否公开
  497. searched: formState.searched ? '1' : '0', //是否展示
  498. externalApply: formState.externalApply ? '1' : '0', //外部申请
  499. isShow: formState.share ? '1' : '0',
  500. publisher: userinfo?.EMPLOYEE?.NAME, //'系统管理员',
  501. username: userinfo?.EMPLOYEE?.NAME, //'系统管理员',
  502. userid: userinfo?.EMPLOYEE?.EMPLOYEE_ID, //'27AF004A-8BDN-885T-30FU-89DE3388762B',
  503. },
  504. sourcetraces: [],
  505. dataVersionConf: {},
  506. };
  507. };
  508. /**
  509. * 设置表单数据
  510. */
  511. const setFormData = () => {
  512. console.log('表单数据请看', data.detail);
  513. console.log('服务类型', serviceTypes);
  514. console.log('服务标签', serviceTags);
  515. console.log('密级', secrets);
  516. console.log('坐标系', sysCoors);
  517. console.log('责任科室', respDept);
  518. console.log('保管部门', collectDept);
  519. console.log('EPSGCodes', EPSGCodes);
  520. formState.public = data.detail.ispublic === '1' ? true : false;
  521. formState.servicename = data.detail?.servicename;
  522. formState.publishtime = data.detail?.publishdate
  523. ? moment(data.detail?.publishdate).format('YYYY-MM-DD HH:mm:ss')
  524. : '';
  525. formState.publisher = data.detail?.publisher;
  526. formState.runtimestatus = data.detail.runtimestatus === 0 ? false : true;
  527. formState.servicealiasname = data.detail?.servicealiasname;
  528. formState.code = data.detail?.serviceid;
  529. formState.servicetype = data.detail?.servicetype;
  530. formState.updatetime = data.detail?.updatedate
  531. ? moment(data.detail?.updatedate).format('YYYY-MM-DD HH:mm:ss')
  532. : '';
  533. formState.servicetype = data.detail?.servicetype;
  534. formState.coordinate = data.detail?.crs;
  535. formState.searched = data.detail.searched === 0 ? false : true;
  536. };
  537. onMounted(() => {
  538. resetForm();
  539. });
  540. return {
  541. ...toRefs(data),
  542. formRef,
  543. moment,
  544. rules,
  545. formState,
  546. submitForm,
  547. resetForm,
  548. createMessage,
  549. setSubmitForm,
  550. setFormData,
  551. };
  552. },
  553. });
  554. </script>
  555. <style scoped lang="less">
  556. .source-detail {
  557. height: 100%;
  558. width: 100%;
  559. padding: 0 20px;
  560. .compontents {
  561. width: 100%;
  562. height: auto;
  563. .title {
  564. height: 19px;
  565. line-height: 18px;
  566. padding-left: 6px;
  567. margin-bottom: 20px;
  568. border-left: 3px solid #0671dd;
  569. font-family: Source Han Sans CN;
  570. font-size: 16px;
  571. font-weight: 350;
  572. letter-spacing: 0px;
  573. }
  574. .form-container {
  575. width: 100%;
  576. height: auto;
  577. .form-col {
  578. height: 100%;
  579. }
  580. .form-col-left {
  581. padding-right: 20px;
  582. }
  583. }
  584. }
  585. }
  586. .label-form-item {
  587. :deep(.ant-form-item-label) {
  588. width: 90px;
  589. }
  590. :deep(.ant-form-item-control) {
  591. width: calc(100% - 90px);
  592. }
  593. }
  594. </style>