editManage.vue 49 KB

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