editManage.vue 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547
  1. <template>
  2. <div>
  3. <el-dialog
  4. :class="'ContentDetail'"
  5. v-model="isDialogShow"
  6. width="650px"
  7. top="7%"
  8. title="内容编辑"
  9. :close-on-click-modal="false"
  10. :before-close="dialogBeforeClose"
  11. style="overflow: auto; height: 700px"
  12. >
  13. <el-form
  14. :model="dataForm"
  15. :rules="dataFormRules"
  16. label-width="150px"
  17. ref="dataForm"
  18. >
  19. <el-form-item :label="'ID(内置)'" v-show="false">
  20. <el-input v-model="dataForm.id" />
  21. </el-form-item>
  22. <el-form-item :label="'标题(内置)'" prop="title" :rules="dataFormRules.required">
  23. <el-input
  24. v-model="dataForm.title"
  25. :placeholder="'请输入标题'"
  26. :disabled="isView"
  27. />
  28. </el-form-item>
  29. <el-form-item
  30. :label="'描述(内置)'"
  31. prop="content"
  32. :rules="dataFormRules.required"
  33. >
  34. <el-input
  35. v-model="dataForm.content"
  36. :placeholder="'请输入描述'"
  37. :disabled="isView"
  38. />
  39. </el-form-item>
  40. <!-- :label="formItem.alias + ':'" -->
  41. <el-form-item
  42. v-for="formItem in modelFieldList"
  43. :key="formItem.name"
  44. :prop="formItem.name"
  45. :rules="formItem.must ? dataFormRules.required : false"
  46. >
  47. <template #label>
  48. <!-- <span title="这里是额外的信息">用户名</span> -->
  49. <span class="el-form-item-label" :title="formItem.alias"
  50. >{{ formItem.alias }}:</span
  51. >
  52. </template>
  53. <!--文本内容-->
  54. <el-input
  55. v-if="['varchar', 'content', 'text'].indexOf(formItem.frontType) > -1"
  56. v-model="dataForm[formItem.name]"
  57. :type="formItem.name == 'password' ? 'password' : 'text'"
  58. :placeholder="formItem.describe"
  59. :disabled="isView"
  60. />
  61. <!--日期时间-->
  62. <span v-else-if="['date_time'].indexOf(formItem.frontType) > -1">
  63. <el-date-picker
  64. v-if="!isView"
  65. type="datetime"
  66. v-model="dataForm[formItem.name]"
  67. value-format="x"
  68. :placeholder="formItem.describe"
  69. />
  70. <span v-else>{{
  71. dataForm[formItem.name] == "" ||
  72. dataForm[formItem.name] == undefined ||
  73. dataForm[formItem.name] == null
  74. ? "无数据"
  75. : handleDateFormat(dataForm[formItem.name], formItem.dateType)
  76. }}</span>
  77. </span>
  78. <!--整数类型-->
  79. <el-input-number
  80. v-if="['int_num'].indexOf(formItem.frontType) > -1"
  81. style="width: 80%"
  82. v-model="dataForm[formItem.name]"
  83. :placeholder="formItem.describe"
  84. :disabled="isView"
  85. />
  86. <!--浮点类型-->
  87. <el-input-number
  88. v-if="['float_num'].indexOf(formItem.frontType) > -1"
  89. :min="formItem.min"
  90. :max="formItem.max"
  91. style="width: 80%"
  92. v-model="dataForm[formItem.name]"
  93. :placeholder="formItem.describe"
  94. :disabled="isView"
  95. />
  96. <!--布尔类型-->
  97. <span v-if="['boolean'].indexOf(formItem.frontType) > -1">
  98. <el-switch
  99. :active-text="'true'"
  100. :inactive-text="'false'"
  101. v-model="dataForm[formItem.name]"
  102. :disabled="isView"
  103. />
  104. <span
  105. style="
  106. font-size: 7px;
  107. color: #606266;
  108. display: inline-block;
  109. margin-left: 8px;
  110. "
  111. >
  112. [{{ formItem.describe }}]
  113. </span>
  114. </span>
  115. <!--单选类型-->
  116. <el-radio-group
  117. v-if="['check'].indexOf(formItem.frontType) > -1"
  118. v-model="dataForm[formItem.name]"
  119. :disabled="isView"
  120. >
  121. <el-radio
  122. v-for="itemItem in itemLists[formItem.extendId]"
  123. :key="itemItem.index"
  124. :label="itemItem.index"
  125. >
  126. {{ itemItem.name }}
  127. </el-radio>
  128. </el-radio-group>
  129. <!--多选类型-->
  130. <el-checkbox-group
  131. v-if="['multiple_check'].indexOf(formItem.frontType) > -1"
  132. v-model="dataForm[formItem.name]"
  133. :disabled="isView"
  134. >
  135. <el-checkbox
  136. v-for="item in itemLists[formItem.extendId]"
  137. :key="item.index"
  138. :label="item.index"
  139. >
  140. {{ item.name }}
  141. </el-checkbox>
  142. </el-checkbox-group>
  143. <!--类别-->
  144. <el-select
  145. clearable
  146. v-if="['select'].indexOf(formItem.frontType) > -1"
  147. v-model="dataForm[formItem.name]"
  148. :placeholder="formItem.describe"
  149. :disabled="isView"
  150. >
  151. <el-option
  152. v-for="item in itemLists[formItem.extendId]"
  153. :key="item.index"
  154. :label="item.name"
  155. :value="item.index"
  156. >
  157. <div
  158. :style="{
  159. width: '100%',
  160. height: '100%',
  161. 'background-color': item.bgColor,
  162. }"
  163. >
  164. <el-image
  165. style="
  166. width: 25px;
  167. height: 25px;
  168. vertical-align: middle;
  169. margin-right: 3px;
  170. "
  171. :src="item.icon"
  172. fit="fill"
  173. >
  174. <template #error>
  175. <div class="image-slot"></div>
  176. </template>
  177. </el-image>
  178. <span :style="{ color: item.frontColor }">{{ item.name }}</span>
  179. </div>
  180. </el-option>
  181. </el-select>
  182. <!--多级类别-->
  183. <el-cascader
  184. clearable
  185. v-if="['multiple_select'].indexOf(formItem.frontType) > -1"
  186. v-model="dataForm[formItem.name]"
  187. :options="itemLists[formItem.extendId]"
  188. :props="{
  189. label: 'name',
  190. value: 'index',
  191. checkStrictly: true,
  192. emitPath: false,
  193. }"
  194. :disabled="isView"
  195. >
  196. <template #default="{ node, data }">
  197. <div style="display: none">{{ node }}</div>
  198. <div
  199. :style="{
  200. width: '100%',
  201. height: '100%',
  202. 'background-color': data.bgColor,
  203. }"
  204. >
  205. <el-image
  206. style="
  207. width: 25px;
  208. height: 25px;
  209. vertical-align: middle;
  210. margin-right: 3px;
  211. "
  212. :src="data.icon"
  213. fit="fill"
  214. >
  215. <template #error>
  216. <div class="image-slot"></div>
  217. </template>
  218. </el-image>
  219. <span :style="{ color: data.frontColor }">{{ data.name }}</span>
  220. </div>
  221. </template>
  222. </el-cascader>
  223. <!-- 经纬度、点、线、面选择-->
  224. <span
  225. v-if="
  226. [
  227. 'latlng',
  228. 'point',
  229. 'polyline',
  230. 'polygon',
  231. 'spoint',
  232. 'spolyline',
  233. 'spolygon',
  234. 'map_draw',
  235. ].indexOf(formItem.frontType) > -1
  236. "
  237. >
  238. <el-input v-show="false" v-model="dataForm[formItem.name]" />
  239. <el-button @click="handleMapSelect(formItem)">
  240. <span>{{ isView ? "查看" : "设置" }}</span
  241. >地理元素
  242. </el-button>
  243. <el-icon
  244. :color="'green'"
  245. style="margin: 0 5px"
  246. v-if="dataForm[formItem.name] && dataForm[formItem.name] != ''"
  247. >
  248. <ElIconCircleCheck />
  249. </el-icon>
  250. <span
  251. style="
  252. font-size: 10px;
  253. color: #606266;
  254. display: inline-block;
  255. margin-left: 5px;
  256. "
  257. >
  258. {{ formItem.describe }}
  259. </span>
  260. </span>
  261. <!--文件/图片/音频/视频-->
  262. <span
  263. v-if="['files', 'picture', 'video', 'audio'].indexOf(formItem.frontType) > -1"
  264. >
  265. <el-upload
  266. :ref="formItem.name + '-upload'"
  267. :file-list="dataForm[formItem.name + '-fileList']"
  268. :limit="1"
  269. :http-request="(options) => handleUpload(options, formItem.name)"
  270. :before-upload="
  271. (rawFile) =>
  272. handleBeforeUpload(
  273. rawFile,
  274. formItem.name + '-upload',
  275. formItem.frontType
  276. )
  277. "
  278. :on-exceed="(val) => handleUploadExceed(val, formItem.name)"
  279. :before-remove="(val) => handleUploadRemove(val, formItem.name)"
  280. :on-preview="(file) => handlePreview(file, formItem.frontType)"
  281. :disabled="isView"
  282. >
  283. <el-input
  284. v-model="dataForm[formItem.name]"
  285. :disabled="true"
  286. v-show="false"
  287. />
  288. <el-button type="primary" :disabled="isView">选择文件</el-button>
  289. <el-icon
  290. :color="'green'"
  291. style="margin: 0 5px"
  292. v-if="
  293. dataForm[formItem.name + '-fileStatus'] !== -1 &&
  294. dataForm[formItem.name] &&
  295. dataForm[formItem.name] != ''
  296. "
  297. >
  298. <ElIconCircleCheck />
  299. </el-icon>
  300. <span v-if="dataForm[formItem.name + '-fileStatus'] === -1">
  301. <el-popover
  302. placement="top-start"
  303. trigger="hover"
  304. popper-class="file_warning"
  305. content="文件无法访问"
  306. >
  307. <template #reference>
  308. <el-icon :color="'orange'" style="margin: 0 5px; cursor: help">
  309. <ElIconWarning />
  310. </el-icon>
  311. </template>
  312. </el-popover>
  313. </span>
  314. <template #tip>
  315. <span
  316. class="el-upload__tip"
  317. style="display: inline-block; margin-left: 10px"
  318. >
  319. {{ formItem.describe }}
  320. </span>
  321. </template>
  322. </el-upload>
  323. </span>
  324. <!--带地理位置的图片、音频、视频-->
  325. <span
  326. v-if="
  327. ['picture_location', 'audio_location', 'video_location'].indexOf(
  328. formItem.frontType
  329. ) > -1
  330. "
  331. >
  332. <el-upload
  333. :ref="formItem.name + '-upload'"
  334. :file-list="dataForm[formItem.name + '-fileList']"
  335. :limit="1"
  336. :http-request="
  337. (options) => handleUpload(options, formItem.name + '-file', true)
  338. "
  339. :before-upload="
  340. (rawFile) =>
  341. handleBeforeUpload(rawFile, formItem.name, formItem.frontType)
  342. "
  343. :on-exceed="(val) => handleUploadExceed(val, formItem.name + '-file')"
  344. :before-remove="
  345. (val) => handleUploadRemove(val, formItem.name + '-file', true)
  346. "
  347. :on-preview="(file) => handlePreview(file, formItem.frontType)"
  348. :disabled="isView"
  349. >
  350. <el-button type="primary" :disabled="isView">选择文件</el-button>
  351. <el-icon
  352. :color="'green'"
  353. style="margin: 0 5px"
  354. v-if="
  355. dataForm[formItem.name + '-fileStatus'] !== -1 &&
  356. dataForm[formItem.name + '-file'] &&
  357. dataForm[formItem.name + '-file'] != ''
  358. "
  359. >
  360. <ElIconCircleCheck />
  361. </el-icon>
  362. <span v-if="dataForm[formItem.name + '-fileStatus'] === -1">
  363. <el-popover
  364. placement="top-start"
  365. trigger="hover"
  366. popper-class="file_warning"
  367. content="文件无法访问"
  368. >
  369. <template #reference>
  370. <el-icon :color="'orange'" style="margin: 0 5px; cursor: help">
  371. <ElIconWarning />
  372. </el-icon>
  373. </template>
  374. </el-popover>
  375. </span>
  376. <template #tip>
  377. <span
  378. class="el-upload__tip"
  379. style="display: inline-block; margin-left: 10px"
  380. >
  381. {{ formItem.describe }}
  382. </span>
  383. </template>
  384. </el-upload>
  385. <el-button @click="handleMapSelect(formItem, formItem.name + '-location')">
  386. <span>{{ isView ? "查看" : "设置" }}</span
  387. >地理位置
  388. </el-button>
  389. <el-icon
  390. :color="'green'"
  391. style="margin: 0 5px"
  392. v-if="
  393. dataForm[formItem.name + '-location'] &&
  394. dataForm[formItem.name + '-location'] != ''
  395. "
  396. >
  397. <ElIconCircleCheck />
  398. </el-icon>
  399. </span>
  400. <!--图册-->
  401. <el-upload
  402. v-if="['pictures'].indexOf(formItem.frontType) > -1"
  403. list-type="picture-card"
  404. :file-list="dataForm[formItem.name + '-fileList']"
  405. :disabled="isView"
  406. :http-request="(options) => handleTCUpload(options, formItem.name)"
  407. :on-preview="(file) => handleTCPreview(file)"
  408. >
  409. <el-icon v-if="!isView">
  410. <ElIconPlus />
  411. </el-icon>
  412. </el-upload>
  413. </el-form-item>
  414. </el-form>
  415. <template #footer>
  416. <span class="dialog-footer">
  417. <el-button type="primary" @click="sure" v-if="!isView">确定</el-button>
  418. </span>
  419. </template>
  420. </el-dialog>
  421. <el-dialog
  422. :class="'ContentMap'"
  423. v-model="isMapShow"
  424. v-if="isMapShow"
  425. width="1200px"
  426. top="7%"
  427. bottom="5%"
  428. title="地图选择"
  429. :close-on-click-modal="false"
  430. :before-close="mapDialogBeforeClose"
  431. >
  432. <div style="width: 100%; height: 40px; padding-bottom: 5px" v-if="!isView">
  433. <el-button
  434. style="margin: 5px"
  435. @click="mapMarkPoint"
  436. v-if="
  437. [
  438. 'map_draw',
  439. 'latlng',
  440. 'point',
  441. 'spoint',
  442. 'picture_location',
  443. 'audio_location',
  444. 'video_location',
  445. ].indexOf(currMapItem.frontType) > -1
  446. "
  447. >点标记</el-button
  448. >
  449. <el-button
  450. style="margin: 5px"
  451. @click="mapMarkLine"
  452. v-if="['map_draw', 'polyline', 'spolyline'].indexOf(currMapItem.frontType) > -1"
  453. >线标记</el-button
  454. >
  455. <el-button
  456. style="margin: 5px"
  457. @click="mapMarkPolygon"
  458. v-if="['map_draw', 'polygon', 'spolygon'].indexOf(currMapItem.frontType) > -1"
  459. >面标记</el-button
  460. >
  461. <el-button style="margin: 5px" @click="calcelMark">取消标记</el-button>
  462. </div>
  463. <div id="mapContent">
  464. <div id="mapPicker" style="width: 100%; height: 100%"></div>
  465. </div>
  466. <div id="mapRight">
  467. <el-form :label-position="'top'">
  468. <el-form-item :label="'地理信息预览:'">
  469. <!-- <json-viewer
  470. :style="{ height: '350px', overflow: 'auto' }"
  471. :value="JSON.parse(JSON.stringify(geoJsons))"
  472. :expand-depth="5"
  473. copyable
  474. boxed
  475. sort
  476. ></json-viewer> -->
  477. <div style="position: absolute;z-index: 9;top: 2px;right: 50px;cursor: pointer;" @click="copyText(geoJsons)">复制</div>
  478. <json-editor-vue
  479. class="json-editor"
  480. :modeList="couldView"
  481. :style="{ height: '370px',width: '100%', overflow: 'auto' }"
  482. :modelValue="JSON.parse(JSON.stringify(geoJsons))"
  483. @update:modelValue="changeValue"
  484. />
  485. </el-form-item>
  486. </el-form>
  487. </div>
  488. <template #footer>
  489. <el-button type="primary" @click="mapSure()" v-if="!isView">确定</el-button>
  490. </template>
  491. </el-dialog>
  492. <el-dialog v-if="isMediaShow" v-model="isMediaShow" title="资源预览">
  493. <span v-if="currMedia.images">
  494. <!-- style="width: 200px; height: 200px; margin: 5px" -->
  495. <el-image
  496. w-full
  497. v-for="(item, index) in currMedia.images"
  498. :key="index"
  499. :src="item"
  500. :fit="fit"
  501. />
  502. </span>
  503. <span v-if="currMedia.video">
  504. <video width="500" height="300" :src="currMedia.video" controls></video>
  505. </span>
  506. <span v-if="currMedia.audio">
  507. <audio :src="currMedia.audio" controls></audio>
  508. </span>
  509. <span v-if="currMedia.file">
  510. <el-button>
  511. <a :href="currMedia.file" :download="currMedia.file">点击下载</a>
  512. </el-button>
  513. </span>
  514. </el-dialog>
  515. </div>
  516. </template>
  517. <script>
  518. import { toRaw } from "vue";
  519. import api from "@/api/content";
  520. import { genFileId, ElLoading } from "element-plus";
  521. import moment from 'moment';
  522. export default {
  523. name: "contentDetail",
  524. data() {
  525. return {
  526. isDialogShow: true,
  527. dataForm: {},
  528. dataFormRules: {
  529. required: [
  530. { required: true, message: "该字段不能为空", trigger: "blur" },
  531. { required: true, message: "该字段不能为空", trigger: "change" },
  532. ],
  533. },
  534. modelFieldList: [],
  535. itemLists: {},
  536. map: {},
  537. currMapItem: {},
  538. isMapShow: true,
  539. mapMarkers: {
  540. layers: [],
  541. points: [],
  542. linePoints: [],
  543. polPoints: [],
  544. lines: [],
  545. pols: [],
  546. },
  547. mapLines: [],
  548. geoJsons: [],
  549. isMediaShow: false,
  550. currMedia: {
  551. images: [],
  552. },
  553. mediaTypes: {
  554. image: ["image/gif", "image/jpeg", "image/jpg", "image/bmp", "image/png"],
  555. video: ["video/mp4"],
  556. audio: ["audio/mpeg"],
  557. },
  558. couldView: ["code"] // "tree", "code", "form", "view"
  559. };
  560. },
  561. props: {
  562. isShow: Boolean,
  563. columnModel: Object,
  564. column: Object,
  565. item: Object,
  566. isView: Boolean,
  567. close: Function,
  568. },
  569. created() {
  570. let that = this;
  571. let modelFields = JSON.parse(this.columnModel.fieldList);
  572. // 无序
  573. let keys = Object.keys(modelFields)
  574. for (let i = 0; i < keys.length; i++) {
  575. let obj = modelFields[keys[i]];
  576. if (!obj.name) {
  577. obj = JSON.parse(obj)
  578. }
  579. obj["key"] = keys[i];
  580. if (["check", "multiple_check"].indexOf(obj.frontType) > -1) {
  581. this.getCheckItems(obj, 1);
  582. } else if (["select", "multiple_select"].indexOf(obj.frontType) > -1) {
  583. this.getCheckItems(obj, 2);
  584. }
  585. this.modelFieldList.push(obj);
  586. }
  587. // 有序
  588. // for (let key in modelFields) {
  589. // let obj = modelFields[key];
  590. // if (!obj.name) {
  591. // obj = JSON.parse(obj);
  592. // }
  593. // obj["key"] = key;
  594. // if (["check", "multiple_check"].indexOf(obj.frontType) > -1) {
  595. // this.getCheckItems(obj, 1);
  596. // } else if (["select", "multiple_select"].indexOf(obj.frontType) > -1) {
  597. // this.getCheckItems(obj, 2);
  598. // }
  599. // debugger
  600. // console.log(1111);
  601. // this.modelFieldList.push(obj);
  602. // }
  603. this.modelFieldList.sort((a, b) => {
  604. // return a.index > b.index ? 1 : a.sequence > b.sequence ? 1 : -1;
  605. return a.index > b.index ? 1 : -1;
  606. });
  607. if (this.item && this.item !== "" && JSON.stringify(this.item) != "{}") {
  608. this.modelFieldList.forEach((data) => {
  609. if (
  610. [
  611. "latlng",
  612. "point",
  613. "polyline",
  614. "polygon",
  615. "spoint",
  616. "spolyline",
  617. "spolygon",
  618. ].indexOf(data.frontType) > -1
  619. ) {
  620. that.item[data.name] = that.item[data.name];
  621. } else if (
  622. ["picture_location", "audio_location", "video_location"].indexOf(
  623. data.frontType
  624. ) > -1
  625. ) {
  626. let obj = JSON.parse(that.item[data.name]);
  627. that.item[data.name + "-file"] = obj.url;
  628. api
  629. .getContentFile(obj.url)
  630. .then((response) => {
  631. that.item[data.name + "-fileList"] = [];
  632. let file = new File(
  633. [response],
  634. that.item[data.name].substr(
  635. that.item[data.name].length - 40,
  636. that.item[data.name].length
  637. )
  638. );
  639. file.serverUrl = obj.url;
  640. that.item[data.name + "-fileList"].push(file);
  641. })
  642. .catch((err) => {
  643. if (err.response.status !== 200) {
  644. that.item[data.name + "-fileStatus"] = -1;
  645. }
  646. });
  647. that.item[data.name + "-location"] = obj.location;
  648. } else if ("multiple_check" == data.frontType) {
  649. if (!that.item[data.name]) {
  650. that.item[data.name] = [];
  651. } else {
  652. let val = [];
  653. let splice = that.item[data.name].split(",");
  654. for (let i = 0; i < splice.length; i++) {
  655. val.push(Number(splice[i]));
  656. }
  657. that.item[data.name] = val;
  658. }
  659. } else if (["check", "select", "multiple_select"].indexOf(data.frontType) > -1) {
  660. that.item[data.name] = Number(that.item[data.name]);
  661. } else if (["files", "picture", "audio", "video"].indexOf(data.frontType) > -1) {
  662. if (!that.item[data.name]) return;
  663. api
  664. .getContentFile(that.item[data.name])
  665. .then((response) => {
  666. that.item[data.name + "-fileList"] = [];
  667. let file = new File(
  668. [response],
  669. that.item[data.name].substr(
  670. that.item[data.name].length - 40,
  671. that.item[data.name].length
  672. )
  673. );
  674. file.serverUrl = that.item[data.name];
  675. that.item[data.name + "-fileList"].push(file);
  676. })
  677. .catch((err) => {
  678. if (err.response.status !== 200) {
  679. that.item[data.name + "-fileStatus"] = -1;
  680. }
  681. });
  682. } else if ("pictures" === data.frontType) {
  683. if (!that.item[data.name]) {
  684. that.item[data.name + "-fileList"] = [];
  685. return;
  686. }
  687. let obj = JSON.parse(that.item[data.name]);
  688. that.item[data.name + "-fileList"] = [];
  689. obj.forEach((i) => {
  690. let url =
  691. i.indexOf(systemConfig.dmsDataProxy) !== 0
  692. ? systemConfig.dmsDataProxy + i
  693. : i;
  694. that.item[data.name + "-fileList"].push({
  695. name: i.substr(i.length - 40, i.length),
  696. url: url,
  697. serverUrl: i,
  698. });
  699. });
  700. }
  701. });
  702. }
  703. this.dataForm = this.item;
  704. // console.log(this.dataForm)
  705. },
  706. mounted() {
  707. this.isMapShow = false;
  708. },
  709. methods: {
  710. async textToCopy(){
  711. let that = this;
  712. // copyText(JSON.stringify(that.geoJsons))
  713. await navigator.clipboard.writeText(JSON.stringify(that.geoJsons));
  714. this.$message({ message: "复制成功", type: "success" });
  715. },
  716. changeValue(json){
  717. let that = this;
  718. let Icon = L.divIcon({
  719. className: "my-div-icon", //自定义icon css样式
  720. iconSize: [10, 10], //点大小
  721. });
  722. that.geoJsons = json
  723. let center = that.geoJsons[0].geometry.coordinates;
  724. let type = that.geoJsons[0].geometry.type;
  725. if(type == "Point"){//更新点坐标
  726. that.mapMarkers.points[0].setLatLng([center[1],center[0]]);
  727. }else if(type == 'LineString'){ // 更新面数据
  728. let geojsons = [];
  729. that.mapMarkers.layers.forEach((item) => {
  730. that.map.removeLayer(item);
  731. });
  732. that.mapMarkers = {
  733. layers: [],
  734. points: [],
  735. linePoints: [],
  736. polPoints: [],
  737. lines: [],
  738. pols: [],
  739. };
  740. for (var i = 0; i < that.geoJsons.length; i++) {
  741. that.geoJsons[i].geometry.coordinates.forEach((item) => {
  742. let marker = L.marker([item[1],item[0]], {
  743. icon: Icon,
  744. }).addTo(that.map);
  745. if (["polyline", "spolyline"].indexOf(that.currMapItem.frontType) > -1) {
  746. that.mapMarkers.lines.forEach((item) => {
  747. that.map.removeLayer(item);
  748. });
  749. that.mapMarkers.lines = [];
  750. geojsons = [];
  751. }
  752. //添加点到地图中
  753. that.mapMarkers.linePoints.push(marker);
  754. that.mapMarkers.layers.push(marker);
  755. if (that.mapMarkers.linePoints.length > 1) {
  756. let points = [];
  757. that.mapMarkers.linePoints.forEach((item) => {
  758. points.push([item._latlng.lat, item._latlng.lng]);
  759. });
  760. let line = L.polyline(points, {
  761. color: "red",
  762. }).addTo(that.map);
  763. that.mapMarkers.layers.push(line);
  764. if (
  765. that.currMapItem.frontType == "map_draw" &&
  766. that.mapMarkers.linePoints.length > 2
  767. ) {
  768. let lastLine = that.mapMarkers.lines[that.mapMarkers.lines.length - 1];
  769. that.map.removeLayer(lastLine);
  770. that.mapMarkers.lines.splice(that.mapMarkers.lines.length - 1, 1);
  771. geojsons.splice(geojsons.length - 1, 1);
  772. }
  773. that.mapMarkers.lines.push(line);
  774. geojsons.push(line.toGeoJSON())
  775. }
  776. });
  777. }
  778. that.geoJsons = geojsons
  779. }else if(type == 'Polygon'){
  780. let geojsons = [];
  781. that.mapMarkers.layers.forEach((item) => {
  782. that.map.removeLayer(item);
  783. });
  784. that.mapMarkers = {
  785. layers: [],
  786. points: [],
  787. linePoints: [],
  788. polPoints: [],
  789. lines: [],
  790. pols: [],
  791. };
  792. for (var i = 0; i < that.geoJsons.length; i++) {
  793. that.geoJsons[i].geometry.coordinates.forEach((coordItem) => {
  794. coordItem.forEach((item) => {
  795. let marker = L.marker([item[1],item[0]], {
  796. icon: Icon,
  797. }).addTo(that.map);
  798. //添加点到地图中
  799. that.mapMarkers.polPoints.push(marker);
  800. that.mapMarkers.layers.push(marker);
  801. if (["polygon", "spolygon"].indexOf(that.currMapItem.frontType) > -1) {
  802. that.mapMarkers.pols.forEach((item) => {
  803. that.map.removeLayer(item);
  804. });
  805. that.mapMarkers.pols = [];
  806. geojsons = [];
  807. }
  808. if (that.mapMarkers.polPoints.length > 2) {
  809. let points = [];
  810. that.mapMarkers.polPoints.forEach((item) => {
  811. points.push([item._latlng.lat, item._latlng.lng]);
  812. });
  813. let polygon = L.polygon(points, {
  814. color: "red",
  815. }).addTo(that.map);
  816. that.mapMarkers.layers.push(polygon);
  817. if (
  818. that.currMapItem.frontType == "map_draw" &&
  819. that.mapMarkers.polPoints.length > 3
  820. ) {
  821. let lastPol = that.mapMarkers.pols[that.mapMarkers.pols.length - 1];
  822. that.map.removeLayer(lastPol);
  823. that.mapMarkers.pols.splice(that.mapMarkers.pols.length - 1, 1);
  824. geojsons.splice(geojsons.length - 1, 1);
  825. }
  826. that.mapMarkers.pols.push(polygon);
  827. geojsons.push(polygon.toGeoJSON());
  828. }
  829. })
  830. })
  831. }
  832. that.geoJsons = geojsons
  833. }
  834. let bboxObj = {
  835. type: "FeatureCollection",
  836. features: that.geoJsons.map(function (item) {
  837. if (item.type == "Feature") {
  838. return item;
  839. } else {
  840. return {
  841. type: "Feature",
  842. geometry: item,
  843. };
  844. }
  845. }),
  846. };
  847. let extent = turf.bbox(bboxObj);
  848. var bounds = L.latLngBounds([
  849. [extent[3], extent[2]],
  850. [extent[1], extent[0]],
  851. ]);
  852. //定位到矩形
  853. that.map.fitBounds(bounds,{ padding: [10, 10], maxZoom: 15 });
  854. },
  855. dialogBeforeClose() {
  856. this.close();
  857. },
  858. mapDialogBeforeClose() {
  859. this.isMapShow = false;
  860. this.calcelMark();
  861. this.geoJsons = [];
  862. this.mapMarkers = {
  863. layers: [],
  864. points: [],
  865. linePoints: [],
  866. polPoints: [],
  867. lines: [],
  868. pols: [],
  869. };
  870. },
  871. handleMapFileChange(name) {
  872. if (
  873. this.dataForm[name + "-file"] &&
  874. this.dataForm[name + "-file"] !== "" &&
  875. this.dataForm[name + "-location"] &&
  876. this.dataForm[name + "-location"] !== ""
  877. ) {
  878. let obj = {
  879. location: this.dataForm[name + "-location"],
  880. url: this.dataForm[name + "-file"],
  881. };
  882. this.dataForm[name] = obj;
  883. } else {
  884. this.dataForm[name] = "";
  885. }
  886. this.$refs.dataForm.validateField(name);
  887. },
  888. mapSure() {
  889. this.isMapShow = false;
  890. if (this.geoJsons.length < 1) {
  891. this.dataForm[this.currMapItem.name] = null;
  892. } else {
  893. if (
  894. [
  895. "latlng",
  896. "point",
  897. "spoint",
  898. "polyline",
  899. "spolyline",
  900. "polygon",
  901. "spolygon",
  902. "picture_location",
  903. "audio_location",
  904. "video_location",
  905. ].indexOf(this.currMapItem.frontType) > -1
  906. ) {
  907. this.dataForm[this.currMapItem.name] = this.$WKT.convert(
  908. this.geoJsons[0].geometry
  909. );
  910. } else {
  911. let geoCollection = {
  912. type: "FeatureCollection",
  913. features: [],
  914. };
  915. this.geoJsons.forEach((item) => {
  916. geoCollection.features.push(toRaw(item));
  917. });
  918. this.dataForm[this.currMapItem.name] = JSON.stringify(geoCollection);
  919. }
  920. }
  921. if (
  922. ["picture_location", "audio_location", "video_location"].indexOf(
  923. this.currMapItem.frontType
  924. ) > -1
  925. ) {
  926. this.handleMapFileChange(
  927. this.currMapItem.name.substr(0, this.currMapItem.name.length - 9)
  928. );
  929. }
  930. this.calcelMark();
  931. this.geoJsons = [];
  932. this.mapMarkers = {
  933. layers: [],
  934. points: [],
  935. linePoints: [],
  936. polPoints: [],
  937. lines: [],
  938. pols: [],
  939. };
  940. },
  941. mapMarkPoint() {
  942. let that = this;
  943. that.map.off("click");
  944. let Icon = L.divIcon({
  945. className: "my-div-icon", //自定义icon css样式
  946. iconSize: [10, 10], //点大小
  947. });
  948. that.map.on("click", function (e) {
  949. var lat = e.latlng.lat; //纬度
  950. var lng = e.latlng.lng; //经度
  951. //打点
  952. if (
  953. [
  954. "latlng",
  955. "point",
  956. "spoint",
  957. "picture_location",
  958. "audio_location",
  959. "video_location",
  960. ].indexOf(that.currMapItem.frontType) > -1 &&
  961. that.mapMarkers.points.length > 0
  962. ) {
  963. //更新点坐标
  964. that.mapMarkers.points[0].setLatLng([lat, lng]);
  965. that.geoJsons[0] = that.mapMarkers.points[0].toGeoJSON();
  966. } else {
  967. let marker = L.marker([lat, lng], {
  968. icon: Icon,
  969. }).addTo(that.map);
  970. //添加点到地图中
  971. that.mapMarkers.points.push(marker);
  972. that.mapMarkers.layers.push(marker);
  973. that.geoJsons.push(marker.toGeoJSON());
  974. }
  975. });
  976. },
  977. mapMarkLine() {
  978. let that = this;
  979. if (this.currMapItem.frontType == "map_draw") {
  980. that.mapMarkers.linePoints = [];
  981. }
  982. that.map.off("click");
  983. let Icon = L.divIcon({
  984. className: "my-div-icon", //自定义icon css样式
  985. iconSize: [10, 10], //点大小
  986. });
  987. that.map.on("click", function (e) {
  988. var lat = e.latlng.lat; //纬度
  989. var lng = e.latlng.lng; //经度
  990. let marker = L.marker([lat, lng], {
  991. icon: Icon,
  992. }).addTo(that.map);
  993. if (["polyline", "spolyline"].indexOf(that.currMapItem.frontType) > -1) {
  994. that.mapMarkers.lines.forEach((item) => {
  995. that.map.removeLayer(item);
  996. });
  997. that.mapMarkers.lines = [];
  998. that.geoJsons = [];
  999. }
  1000. //添加点到地图中
  1001. that.mapMarkers.linePoints.push(marker);
  1002. that.mapMarkers.layers.push(marker);
  1003. if (that.mapMarkers.linePoints.length > 1) {
  1004. let points = [];
  1005. that.mapMarkers.linePoints.forEach((item) => {
  1006. points.push([item._latlng.lat, item._latlng.lng]);
  1007. });
  1008. let line = L.polyline(points, {
  1009. color: "red",
  1010. }).addTo(that.map);
  1011. that.mapMarkers.layers.push(line);
  1012. if (
  1013. that.currMapItem.frontType == "map_draw" &&
  1014. that.mapMarkers.linePoints.length > 2
  1015. ) {
  1016. let lastLine = that.mapMarkers.lines[that.mapMarkers.lines.length - 1];
  1017. that.map.removeLayer(lastLine);
  1018. that.mapMarkers.lines.splice(that.mapMarkers.lines.length - 1, 1);
  1019. that.geoJsons.splice(that.geoJsons.length - 1, 1);
  1020. }
  1021. that.mapMarkers.lines.push(line);
  1022. that.geoJsons.push(line.toGeoJSON());
  1023. }
  1024. });
  1025. },
  1026. mapMarkPolygon() {
  1027. let that = this;
  1028. if (this.currMapItem.frontType == "map_draw") {
  1029. that.mapMarkers.polPoints = [];
  1030. }
  1031. that.map.off("click");
  1032. let Icon = L.divIcon({
  1033. className: "my-div-icon", //自定义icon css样式
  1034. iconSize: [10, 10], //点大小
  1035. });
  1036. that.map.on("click", function (e) {
  1037. var lat = e.latlng.lat; //纬度
  1038. var lng = e.latlng.lng; //经度
  1039. let marker = L.marker([lat, lng], {
  1040. icon: Icon,
  1041. }).addTo(that.map);
  1042. //添加点到地图中
  1043. that.mapMarkers.polPoints.push(marker);
  1044. that.mapMarkers.layers.push(marker);
  1045. if (["polygon", "spolygon"].indexOf(that.currMapItem.frontType) > -1) {
  1046. that.mapMarkers.pols.forEach((item) => {
  1047. that.map.removeLayer(item);
  1048. });
  1049. that.mapMarkers.pols = [];
  1050. that.geoJsons = [];
  1051. }
  1052. if (that.mapMarkers.polPoints.length > 2) {
  1053. let points = [];
  1054. that.mapMarkers.polPoints.forEach((item) => {
  1055. points.push([item._latlng.lat, item._latlng.lng]);
  1056. });
  1057. let polygon = L.polygon(points, {
  1058. color: "red",
  1059. }).addTo(that.map);
  1060. that.mapMarkers.layers.push(polygon);
  1061. if (
  1062. that.currMapItem.frontType == "map_draw" &&
  1063. that.mapMarkers.polPoints.length > 3
  1064. ) {
  1065. let lastPol = that.mapMarkers.pols[that.mapMarkers.pols.length - 1];
  1066. that.map.removeLayer(lastPol);
  1067. that.mapMarkers.pols.splice(that.mapMarkers.pols.length - 1, 1);
  1068. that.geoJsons.splice(that.geoJsons.length - 1, 1);
  1069. }
  1070. that.mapMarkers.pols.push(polygon);
  1071. that.geoJsons.push(polygon.toGeoJSON());
  1072. }
  1073. });
  1074. },
  1075. calcelMark() {
  1076. let that = this;
  1077. that.map.off("click");
  1078. that.mapMarkers.layers.forEach((item) => {
  1079. that.map.removeLayer(item);
  1080. });
  1081. that.mapMarkers = {
  1082. layers: [],
  1083. points: [],
  1084. linePoints: [],
  1085. polPoints: [],
  1086. lines: [],
  1087. pols: [],
  1088. };
  1089. this.geoJsons = [];
  1090. },
  1091. handleMapSelect(item, alias) {
  1092. this.isMapShow = true;
  1093. item = JSON.parse(JSON.stringify(item));
  1094. if (alias && alias != "") {
  1095. item.name = alias;
  1096. }
  1097. this.currMapItem = item;
  1098. let that = this;
  1099. this.$nextTick(() => {
  1100. that.map = that.$L.map("mapPicker", {
  1101. minZoom: 3,
  1102. maxZoom: 20,
  1103. // center: [39.915457, 116.453437],
  1104. center: [31.175188130627745, 121.26786280328167],
  1105. zoom: 15,
  1106. zoomControl: false,
  1107. attributionControl: false,
  1108. crs: L.CRS.EPSG4326,
  1109. });
  1110. that.$L
  1111. .tileLayer(systemConfig.VEC_C + systemConfig.TDT_TK, {
  1112. maxZoom: 20,
  1113. tileSize: 256,
  1114. zoomOffset: 1,
  1115. })
  1116. .addTo(that.map);
  1117. that.$L
  1118. .tileLayer(systemConfig.CVA_C + systemConfig.TDT_TK, {
  1119. maxZoom: 20,
  1120. tileSize: 256,
  1121. zoomOffset: 1,
  1122. })
  1123. .addTo(that.map);
  1124. if (that.dataForm[item.name]) {
  1125. let Icon = L.divIcon({
  1126. className: "my-div-icon", //自定义icon css样式
  1127. iconSize: [10, 10], //点大小
  1128. });
  1129. let geojsons = [];
  1130. if (that.currMapItem.frontType != "map_draw") {
  1131. if (that.dataForm[item.name].value) {
  1132. geojsons.push(that.$WKT.parse(that.dataForm[item.name].value));
  1133. } else {
  1134. geojsons.push(that.$WKT.parse(that.dataForm[item.name]));
  1135. }
  1136. } else {
  1137. let obj = JSON.parse(that.dataForm[item.name]);
  1138. if (obj.features && obj.features !== "") {
  1139. obj.features.forEach((i) => geojsons.push(i));
  1140. }
  1141. }
  1142. let bboxObj = {
  1143. type: "FeatureCollection",
  1144. features: geojsons.map(function (item) {
  1145. if (item.type == "Feature") {
  1146. return item;
  1147. } else {
  1148. return {
  1149. type: "Feature",
  1150. geometry: item,
  1151. };
  1152. }
  1153. }),
  1154. };
  1155. let extent = turf.bbox(bboxObj);
  1156. var bounds = L.latLngBounds([
  1157. [extent[3], extent[2]],
  1158. [extent[1], extent[0]],
  1159. ]);
  1160. //定位到矩形
  1161. that.map.fitBounds(bounds);
  1162. // console.log(t)
  1163. for (let i = 0; i < geojsons.length; i++) {
  1164. let layer = that.$L
  1165. .geoJSON(geojsons[i], {
  1166. onEachFeature: function (feature, layer) {
  1167. if (feature.properties && feature.properties.name) {
  1168. layer.bindTooltip(feature.properties.name);
  1169. layer.bindPopup(feature.properties.address);
  1170. }
  1171. },
  1172. pointToLayer: function (feature, latlng) {
  1173. let marker = L.marker(latlng, {
  1174. icon: Icon,
  1175. });
  1176. that.mapMarkers.points.push(marker);
  1177. return marker;
  1178. },
  1179. })
  1180. .addTo(that.map);
  1181. that.geoJsons.push(layer.toGeoJSON().features[0]);
  1182. }
  1183. }
  1184. });
  1185. },
  1186. handleBeforeUpload(file, ref, type) {
  1187. let fileType = file.type;
  1188. let fileSize = file.size / 1024 / 1024;
  1189. // 判断类型
  1190. if (["picture", "picture_location"].indexOf(type) > -1) {
  1191. if (this.mediaTypes.image.indexOf(fileType) < 0) {
  1192. this.$message({ message: "不支持的图片类型", type: "warning" });
  1193. return false;
  1194. }
  1195. } else if (["audio", "audio_location"].indexOf(type) > -1) {
  1196. if (this.mediaTypes.audio.indexOf(fileType) < 0) {
  1197. this.$message({ message: "不支持的音频类型", type: "warning" });
  1198. return false;
  1199. }
  1200. } else if (["video", "video_location"].indexOf(type) > -1) {
  1201. if (this.mediaTypes.video.indexOf(fileType) < 0) {
  1202. this.$message({ message: "不支持的视频类型", type: "warning" });
  1203. return false;
  1204. }
  1205. }
  1206. // 判断大小
  1207. if (["video", "video_location"].indexOf(type) > -1) {
  1208. if (fileSize > 40) {
  1209. this.$message({ message: "文件不能超过40M", type: "warning" });
  1210. return false;
  1211. }
  1212. } else {
  1213. if (fileSize > 10) {
  1214. this.$message({ message: "文件不能超过10M", type: "warning" });
  1215. return false;
  1216. }
  1217. }
  1218. return true;
  1219. },
  1220. handleUpload(options, ref, isMapFile, isMulti) {
  1221. let that = this;
  1222. let params = {
  1223. columnId: this.columnModel.id,
  1224. contentId: this.item.id,
  1225. paraName: options.file.name,
  1226. type: 0,
  1227. file: options.file,
  1228. };
  1229. const loadingInstance = ElLoading.service({
  1230. customClass: "content-detail-upload-loading",
  1231. fullscreen: true,
  1232. text: "上传中,请稍后...",
  1233. });
  1234. api.uploadFile(params).then((res) => {
  1235. if (res.code === 200) {
  1236. loadingInstance.close();
  1237. that.dataForm[ref + "-fileStatus"] = null;
  1238. options.file.serverUrl = res.content;
  1239. if (isMulti) {
  1240. let urls = [];
  1241. that.dataForm[ref + "-fileList"].forEach((i) => {
  1242. let serverUrl = i.raw ? i.raw.serverUrl : i.serverUrl ? i.serverUrl : "";
  1243. urls.push(serverUrl);
  1244. });
  1245. that.dataForm[ref] = urls;
  1246. } else {
  1247. that.dataForm[ref] = res.content;
  1248. }
  1249. if (isMapFile) {
  1250. this.handleMapFileChange(ref.substr(0, ref.length - 5));
  1251. }
  1252. } else {
  1253. loadingInstance.close();
  1254. that.$message({ message: res.content, type: "error" });
  1255. }
  1256. });
  1257. },
  1258. handleUploadExceed(file, ref) {
  1259. this.$refs[ref + "-upload"][0].clearFiles();
  1260. file = file[0];
  1261. file.uid = genFileId();
  1262. this.$refs[ref + "-upload"][0].handleStart(file);
  1263. this.$refs[ref + "-upload"][0].submit();
  1264. },
  1265. handleUploadRemove(file, ref, isMapFile) {
  1266. this.dataForm[ref] = "";
  1267. if (isMapFile) {
  1268. this.handleMapFileChange(ref.substr(0, ref.length - 5));
  1269. }
  1270. },
  1271. handlePreview(file, type) {
  1272. this.isMediaShow = true;
  1273. this.currMedia = {};
  1274. let serverUrl = file.raw
  1275. ? file.raw.serverUrl
  1276. : file.serverUrl
  1277. ? file.serverUrl
  1278. : "";
  1279. let url =
  1280. serverUrl.indexOf(systemConfig.dmsDataProxy) !== 0
  1281. ? systemConfig.dmsDataProxy + serverUrl
  1282. : serverUrl;
  1283. if (["picture", "picture_location"].indexOf(type) > -1) {
  1284. this.currMedia.images = [url];
  1285. } else if (["video", "video_location"].indexOf(type) > -1) {
  1286. this.currMedia.video = url;
  1287. } else if (["audio", "audio_location"].indexOf(type) > -1) {
  1288. this.currMedia.audio = url;
  1289. } else {
  1290. this.currMedia.file = url;
  1291. }
  1292. },
  1293. handleTCUpload(options, ref) {
  1294. let that = this;
  1295. let params = {
  1296. columnId: this.columnModel.id,
  1297. contentId: this.item.id,
  1298. paraName: options.file.name,
  1299. type: 0,
  1300. file: options.file,
  1301. };
  1302. // loading
  1303. const loadingInstance = ElLoading.service({
  1304. customClass: "content-detail-upload-loading",
  1305. fullscreen: true,
  1306. text: "上传中,请稍后...",
  1307. });
  1308. api.uploadFile(params).then((res) => {
  1309. if (res.code === 200) {
  1310. loadingInstance.close();
  1311. that.dataForm[ref + "-fileStatus"] = null;
  1312. options.file.serverUrl = res.content;
  1313. let url = systemConfig.dmsDataProxy + res.content;
  1314. that.dataForm[ref + "-fileList"].push({
  1315. name: options.file.name,
  1316. url: url,
  1317. serverUrl: res.content,
  1318. });
  1319. } else {
  1320. loadingInstance.close();
  1321. that.$message({ message: res.content, type: "error" });
  1322. }
  1323. });
  1324. },
  1325. handleTCPreview(file) {
  1326. file = toRaw(file);
  1327. let serverUrl = file.raw
  1328. ? file.raw.serverUrl
  1329. : file.serverUrl
  1330. ? file.serverUrl
  1331. : "";
  1332. let url =
  1333. serverUrl.indexOf(systemConfig.dmsDataProxy) !== 0
  1334. ? systemConfig.dmsDataProxy + serverUrl
  1335. : serverUrl;
  1336. this.currMedia.images = [url];
  1337. this.isMediaShow = true;
  1338. },
  1339. handleDateFormat(val, fmt) {
  1340. if (!fmt || fmt == "") {
  1341. fmt = "0";
  1342. }
  1343. if (fmt == "0") {
  1344. return moment(val).format('YYYY-MM-DD');
  1345. } else if (fmt == "1") {
  1346. return moment(val).format('YYYY-MM-DD HH:mm:ss');
  1347. } else if (fmt == "2") {
  1348. return moment(val).format('YYYY-MM-DD HH:mm:ss.ssss')
  1349. } else {
  1350. return moment(val).format('YYYY-MM-DD HH:mm:ss');
  1351. }
  1352. },
  1353. sure() {
  1354. let that = this;
  1355. this.$refs.dataForm.validate((valid) => {
  1356. if (valid) {
  1357. console.log('[ eeeee ] >')
  1358. let content = {};
  1359. content["id"] = that.dataForm["id"];
  1360. content["title"] = that.dataForm["title"];
  1361. content["content"] = that.dataForm["content"];
  1362. that.modelFieldList.forEach((field) => {
  1363. if (field.frontType == "multiple_check") {
  1364. if (that.dataForm[field.name] == undefined) that.dataForm[field.name] = [];
  1365. let str = that.dataForm[field.name].join(",");
  1366. str.replace("[", "");
  1367. str.replace("]", "");
  1368. content[field.name] = str;
  1369. } else if (field.frontType == "date_time") {
  1370. content[field.name] = that.dataForm[field.name];
  1371. } else if (field.frontType == "pictures") {
  1372. content[field.name] = [];
  1373. if (that.dataForm[field.name + "-fileList"]) {
  1374. that.dataForm[field.name + "-fileList"].forEach((i) => {
  1375. content[field.name].push(i.serverUrl);
  1376. });
  1377. }
  1378. content[field.name] = JSON.stringify(content[field.name]);
  1379. } else {
  1380. content[field.name] = that.dataForm[field.name];
  1381. }
  1382. });
  1383. let params = {
  1384. content: JSON.stringify(content),
  1385. columnId: that.column.columnId,
  1386. modelId: that.column.modelId,
  1387. };
  1388. if (content.id && content.id !== "") {
  1389. api
  1390. .updateContent(params)
  1391. .then((res) => {
  1392. if (res.code === 200) {
  1393. that.close(true);
  1394. that.$message({ message: "修改成功", type: "success" });
  1395. } else {
  1396. that.$message({ message: res.content, type: "error" });
  1397. }
  1398. })
  1399. .catch((err) => {
  1400. that.$message({ message: err.message, type: "error" });
  1401. });
  1402. } else {
  1403. api
  1404. .addContent(params)
  1405. .then((res) => {
  1406. if (res.code === 200) {
  1407. that.close(true);
  1408. let message = "添加成功";
  1409. if(that.column.columnId == systemConfig.columnIds[3] && that.column.modelId == systemConfig.modelIds[1]){ //指定 一张图登录栏目 申请账号时使用判断
  1410. message = "申请成功!请等待三个工作日后,管理员审核通过后,您才能登录系统。"
  1411. }
  1412. that.$message({ message: message, type: "success" });
  1413. } else {
  1414. that.$message({ message: res.content, type: "error" });
  1415. }
  1416. })
  1417. .catch((err) => {
  1418. that.$message({ message: err.message, type: "error" });
  1419. });
  1420. }
  1421. }
  1422. });
  1423. },
  1424. getCheckItems(item, type) {
  1425. let that = this;
  1426. console.log('[ eee ] >')
  1427. if (type === 1) {
  1428. api.getCheckDetail({ sName: item.extendId }).then((res) => {
  1429. if (res.code == 200) {
  1430. that.itemLists[item.extendId] = res.content;
  1431. }
  1432. });
  1433. } else if (type === 2) {
  1434. let cType =
  1435. item.frontType === "select"
  1436. ? 0
  1437. : item.frontType === "multiple_select"
  1438. ? 1
  1439. : null;
  1440. api.getCategoryDetail({ type: cType, cName: item.extendId }).then((res) => {
  1441. if (res.code == 200) {
  1442. that.itemLists[item.extendId] = res.content;
  1443. }
  1444. });
  1445. }
  1446. },
  1447. },
  1448. };
  1449. </script>
  1450. <style>
  1451. .jsoneditor-menu{
  1452. display: none;
  1453. }
  1454. .jsoneditor-statusbar{
  1455. display: none;
  1456. }
  1457. .jsoneditor-validation-errors-container{
  1458. display: none;
  1459. }
  1460. div.jsoneditor-outer.has-main-menu-bar {
  1461. margin-top: 0px;
  1462. padding-top: 40px;
  1463. background-color: #e2f1fa;
  1464. }
  1465. .full-screen{
  1466. right: 10px !important;
  1467. background-color: #d9d9d9 !important;
  1468. }
  1469. #mapContent {
  1470. height: 400px;
  1471. width: 70%;
  1472. display: inline-block;
  1473. }
  1474. #mapRight {
  1475. padding-left: 10px;
  1476. height: 400px;
  1477. width: 25%;
  1478. display: inline-block;
  1479. vertical-align: top;
  1480. }
  1481. .my-div-icon {
  1482. width: 15px;
  1483. height: 15px;
  1484. background-color: red;
  1485. border-radius: 50%;
  1486. }
  1487. .file_warning {
  1488. background-color: #fdf6ec !important;
  1489. color: #e8a84a !important;
  1490. font-weight: bold;
  1491. }
  1492. .el-form-item .el-form-item-label {
  1493. display: inline-block;
  1494. text-align: right;
  1495. /* 防止文本换行 */
  1496. white-space: nowrap;
  1497. /* 隐藏溢出的内容 */
  1498. overflow: hidden;
  1499. /* 显示省略符号 */
  1500. text-overflow: ellipsis;
  1501. }
  1502. .content-detail-upload-loading svg {
  1503. width: 80px;
  1504. height: 90px;
  1505. }
  1506. .content-detail-upload-loading .el-loading-text {
  1507. font-size: 20px;
  1508. }
  1509. </style>