addNcomplaint.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. <template>
  2. <div class="mainBox">
  3. <div class="layerBox">
  4. <tableTitle :name="tableDivTitle" />
  5. <el-form :model="form" ref="form" :rules="formRules" label-position="left" label-width="120px">
  6. <div class="formDiv">
  7. <el-form-item label="投诉标题:" prop="title" class="custom-align-right">
  8. <el-input v-model="form.title" autocomplete="off" placeholder="请输入投诉标题"></el-input>
  9. </el-form-item>
  10. <el-form-item label="发布范围:" prop="city_arr_id" class="custom-align-right">
  11. <el-cascader :key="cascaderKey" v-model="form.city_arr_id" placeholder="请选择发布范围" :props="cityData"
  12. filterable clearable></el-cascader>
  13. </el-form-item>
  14. <el-form-item label="行政职能:" prop="department_arr_id" class="custom-align-right">
  15. <el-cascader :key="searchDepartmentKey" v-model="form.department_arr_id" placeholder="请选择行政职能"
  16. popper-class="my_cascader" :props="searchDepartmentData" filterable clearable></el-cascader>
  17. </el-form-item>
  18. <el-form-item label="行政人员:" prop="re_user_ids" class="custom-align-right">
  19. <el-select v-model="form.re_user_ids" placeholder="请选择行政人员" multiple filterable clearable
  20. @visible-change="getDUser">
  21. <el-option v-for="item in re_user_ids" :key="item.id" :label="item.user_name + '/' + item.nickname"
  22. :value="item.id">
  23. </el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item label="事件描述:" prop="content" class="custom-align-right">
  27. <el-input v-model="form.content" maxlength="500" autocomplete="off" placeholder="请输入事件描述:" type="textarea"
  28. rows="10"></el-input>
  29. </el-form-item>
  30. <el-form-item label="我的要求:" prop="want" class="custom-align-right">
  31. <el-input v-model="form.want" maxlength="500" autocomplete="off" placeholder="请输入我的要求:" type="textarea"
  32. rows="10"></el-input>
  33. </el-form-item>
  34. <el-form-item label="发生日期:" prop="start" class="custom-align-right">
  35. <el-date-picker v-model="form.start" placeholder="请选择发生日期">
  36. </el-date-picker>
  37. </el-form-item>
  38. <el-form-item label="附件:" class="custom-align-right" prop="">
  39. <div class="uploaderBox" @mouseenter="hovering = true" mouseleave="hovering = false">
  40. <el-upload class="avatar-uploader" action="#" :show-file-list="false" :before-upload="beforeAvatarUpload">
  41. <!-- 预览图片 -->
  42. <img v-if="file && (fileType == 'jpeg' || fileType == 'png')" :src="file" class="avatar">
  43. <div v-if="file && (fileType == 'pdf' || fileType == 'word')" class="chooseImgDiv1">
  44. <div>
  45. <div>{{ file }}</div>
  46. </div>
  47. </div>
  48. <div v-else class="chooseImgDiv">
  49. <div>
  50. <img src="@/assets/public/upload/noImage.png">
  51. <div>选择文档</div>
  52. </div>
  53. </div>
  54. </el-upload>
  55. <input type="hidden" v-model="form.imgurl">
  56. <span class="photo_tips">支持文件形式pdf,word,jpg,文件最大2M。</span>
  57. <div v-if="hovering && imgUrl" class="delete-button" @click="handleDelete">
  58. <i class="el-icon-delete"></i>
  59. </div>
  60. </div>
  61. </el-form-item>
  62. <el-form-item label="投诉方式" prop="type" class="custom-align-right">
  63. <el-radio-group v-model="form.type">
  64. <el-radio :label="1">匿名</el-radio>
  65. <el-radio :label="2">实名</el-radio>
  66. </el-radio-group>
  67. </el-form-item>
  68. <!-- <el-form-item label="建立群聊:" prop="is_group" class="custom-align-right">
  69. <el-radio-group v-model="form.is_group" :disabled="this.$route.query.id != undefined">
  70. <el-radio :label="1">是</el-radio>
  71. <el-radio :label="0">否</el-radio>
  72. </el-radio-group>
  73. </el-form-item>
  74. <el-form-item label="群聊名称:" prop="group_name" class="custom-align-right" v-if="form.is_group == 1"
  75. :disabled="this.$route.query.id != undefined">
  76. <el-input v-model="form.group_name" autocomplete="off" placeholder="请输入群聊名称"></el-input>
  77. </el-form-item> -->
  78. </div>
  79. </el-form>
  80. </div>
  81. <div class="bottomBtnBox" v-if="readStatus == false">
  82. <el-button type="info" @click="returnPage">返回</el-button>
  83. <el-button type="primary" @click="editToServe" v-if="editStatus == true">确定</el-button>
  84. <el-button type="primary" @click="addToServe" v-else>发布投诉举报</el-button>
  85. </div>
  86. </div>
  87. </template>
  88. <script>
  89. //表格标题
  90. import tableTitle from './components/tableTitle';
  91. //引入公用样式
  92. import '@/styles/global.less';
  93. //格式化时间
  94. import { formatLocalDate } from '@/utils/public';
  95. export default {
  96. components: {
  97. tableTitle
  98. },
  99. data() {
  100. //0.全局操作 start ------------------------------------------------------------>
  101. //表单验证
  102. const validateNull = (rule, value, callback) => {
  103. console.log(value, '-------------------------------')
  104. if (value == '' || value == undefined || value == null) {
  105. callback(new Error('该项不能为空!'))
  106. } else {
  107. callback()
  108. }
  109. }
  110. const validateEmpty = (rule, value, callback) => {
  111. console.log(value, '-------------------------------')
  112. if (value.length == 0) {
  113. callback(new Error('该项不能为空!'))
  114. } else {
  115. callback()
  116. }
  117. }
  118. const validateArray = (rule, value, callback) => {
  119. if (value.length == 0) {
  120. callback(new Error('该项不能为空!'))
  121. } else {
  122. callback()
  123. }
  124. }
  125. let self = this;
  126. //0.全局操作 end ------------------------------------------------------------>
  127. return {
  128. hovering: false, // 鼠标悬浮状态 悬浮时显示删除
  129. formLabelWidth: '80px',//表单的长度
  130. //1.表单项 start ------------------------------------------------------------>
  131. editStatus: false,
  132. readStatus: false,
  133. tableDivTitle: "添加投诉举报",
  134. searchCascaderKey: 0, //列表缓存key
  135. website_id: 2,
  136. file: '',
  137. userType: 1, //用户类型 1:普通用户,
  138. pickerOptions: {
  139. selectableRange: '1900-01-01 to 2100-12-31', // 允许选择的日期范围
  140. // disabledDate(time) {
  141. // return time.getTime() < Date.now() - 86400000; // 禁用今天之前的日期
  142. // },
  143. },
  144. //提交表单
  145. form: {
  146. //1.1使用了外链
  147. title: '',//投诉举报标题
  148. type: 1,//类型:1:公告,2:投诉举报
  149. level: 1,//级别:1:常规,2:紧急,3:特急
  150. city_arr_id: [],//行政区划
  151. city_id: '',//城市id
  152. content: "",
  153. file: "",//文件路径
  154. department_arr_id: [],//部门id
  155. department_id: '',//部门id
  156. want: "",//我的要求
  157. type: 1,//发布类型:1:匿名,2:实名
  158. start: '',//开始时间
  159. re_user_ids: [],//行政人员id
  160. },
  161. //1.2 表单验证规则
  162. formRules: {
  163. title: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  164. type: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  165. city_arr_id: [{ required: true, trigger: 'blur', validator: validateArray }],
  166. department_arr_id: [{ required: true, trigger: 'blur', validator: validateArray }],
  167. re_user_ids: [{ required: true, trigger: 'blur', validator: validateArray }],
  168. level: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  169. content: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  170. address: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  171. is_group: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  172. },
  173. //1.3富文本编辑器配置
  174. showHtml: false, //用于保存源码内容
  175. editorHtml: '',
  176. cascaderKey: 0,//弹窗用的key
  177. websiteData: {
  178. lazy: true,
  179. checkStrictly: true,
  180. async lazyLoad(node, resolve) {
  181. const { level, data } = node;
  182. if (data && data.children && data.children.length !== 0) {
  183. return resolve(node)
  184. }
  185. console.log(level)
  186. let parentId = level == 0 ? 0 : data.value
  187. let parames = {
  188. 'page': 1,
  189. 'pageSize': 1000,
  190. }
  191. self.$store.dispatch('news/websiteList', parames).then(res => {
  192. if (res.data) {
  193. const nodes = res.data.rows.map(item => ({
  194. value: item.id,
  195. label: item.website_name,
  196. leaf: level >= 3,
  197. children: []
  198. }))
  199. console.log(nodes, 'leaf')
  200. resolve(nodes)
  201. }
  202. })
  203. },
  204. },
  205. cityData: {
  206. checkStrictly: true,
  207. lazy: true,
  208. async lazyLoad(node, resolve) {
  209. const { level, data } = node;
  210. if (data && data.children && data.children.length !== 0) {
  211. return resolve(node)
  212. }
  213. console.log(level, '====level-----')
  214. let parentId = level == 0 ? 0 : data.value
  215. let parames = {
  216. 'pid': parentId
  217. }
  218. self.$store.dispatch('pool/getcityList', parames).then(res => {
  219. if (res.data) {
  220. const nodes = res.data.map(item => ({
  221. value: item.id,
  222. label: item.name,
  223. leaf: level >= 3,
  224. children: []
  225. }))
  226. resolve(nodes)
  227. }
  228. })
  229. }
  230. },
  231. imgurl: [],
  232. //获取父级导航池
  233. parentKey: 0,//获取父级导航
  234. parentData: {
  235. checkStrictly: true,
  236. lazy: true,
  237. async lazyLoad(node, resolve) {
  238. console.log(resolve, 'node')
  239. const { level, data } = node;
  240. if (data && data.children && data.children.length !== 0) {
  241. return resolve(node)
  242. }
  243. console.log(level, 'level--1--');
  244. let pid = level == 0 ? 0 : data.value
  245. let website_id = self.form.website_id == '' ? 2 : self.form.website_id;
  246. console.log(website_id, 'website_id--111-----');
  247. let parames = {
  248. 'website_id': website_id,
  249. 'pid': pid
  250. }
  251. self.$store.dispatch('news/getWebsiteNavList', parames).then(res => {
  252. if (res.data) {
  253. const nodes = res.data.map(item => ({
  254. value: item.category_id,
  255. label: item.name,
  256. leaf: level >= 3,
  257. children: []
  258. }))
  259. resolve(nodes)
  260. } else {
  261. //输出报错原因
  262. console.log(res.msg, 'getWebsiteNavList--1--');
  263. }
  264. })
  265. }
  266. },
  267. //行政职能部门
  268. searchDepartmentKey: 0, //列表缓存key
  269. searchDepartmentData: {
  270. checkStrictly: true,
  271. lazy: true,
  272. async lazyLoad(node, resolve) {
  273. const { level, data } = node;
  274. if (data && data.children && data.children.length !== 0) {
  275. return resolve(node)
  276. }
  277. console.log(level)
  278. let parentId = level == 0 ? 0 : data.value
  279. let parames = {
  280. 'pid': parentId
  281. }
  282. self.$store.dispatch('pool/getDepartment', parames).then(res => {
  283. if (res.data) {
  284. const nodes = res.data.map(item => ({
  285. value: item.id,
  286. label: item.name,
  287. leaf: level >= 3,
  288. children: []
  289. }))
  290. resolve(nodes)
  291. }
  292. })
  293. }
  294. },
  295. inputList: [
  296. { value: '' }
  297. ]
  298. //表单项 end ------------------------------------------------------------>
  299. };
  300. },
  301. methods: {
  302. //获取行政人员
  303. getDUser() {
  304. this.$forceUpdate();
  305. let department_id = this.form.department_arr_id;
  306. let city_id = this.form.city_arr_id;
  307. if (department_id.length == 0) {
  308. this.$message.warning('请选择行政职能');
  309. return;
  310. }
  311. if (city_id.length == 0) {
  312. this.$message.warning('请选择行政区划');
  313. return;
  314. }
  315. department_id = department_id.at(-1) || 0;
  316. city_id = city_id.at(-1) || 0;
  317. let parames = {
  318. 'department_id': department_id,
  319. 'city_id': city_id,
  320. }
  321. //如果是编辑,就返回数据
  322. // if (this.$route.query.id != undefined) {
  323. // let ids = Array.isArray(this.form.re_user_ids) ? this.form.re_user_ids : JSON.parse(this.form.re_user_ids)
  324. // if (ids.length > 0) {
  325. // parames = {
  326. // 'ids': ids,
  327. // }
  328. // } else {
  329. // this.$message({
  330. // type: 'info',
  331. // message: '用户数据为空'
  332. // });
  333. // return;
  334. // }
  335. // }
  336. this.$store.dispatch('news/getDUser', parames).then(res => {
  337. // this.form.re_user_ids = res.data;
  338. this.re_user_ids = res.data;
  339. this.$forceUpdate();
  340. }).catch(() => {
  341. this.$message({
  342. type: 'info',
  343. message: '网络错误,请重试!'
  344. });
  345. })
  346. },
  347. async fetchWebsiteOptions() {
  348. try {
  349. const response = await this.$store.dispatch('news/websiteList', { page: 1, pageSize: 1000 });
  350. if (response && response.data) {
  351. this.websiteOptions = response.data.rows.map(item => ({
  352. value: item.id,
  353. label: item.website_name,
  354. }));
  355. }
  356. } catch (error) {
  357. console.error('获取网站列表失败:', error);
  358. }
  359. },
  360. //获取用户身份信息
  361. getUserInfo() {
  362. this.$store.dispatch('public/getInfo').then(res => {
  363. console.log(res)
  364. this.userType = res.data.type_id;
  365. //个人会员=1 政务会员=2 企业会员=3 调研员=4 管理员=10000 游客=20000
  366. }).catch(() => {
  367. this.$message({
  368. type: 'info',
  369. message: '网络错误,请重试!'
  370. });
  371. })
  372. },
  373. //1.提交表单 start ------------------------------------------------------------>
  374. beforeAvatarUpload(file) {
  375. const isJPG = file.type === 'image/jpeg';
  376. const isPNG = file.type === 'image/png';
  377. //word pdf
  378. const isWord = file.type === 'application/msword' || file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' || file.type === 'application/vnd.ms-word' || file.type === 'doc';
  379. const isPdf = file.type === 'application/pdf' || file.type === 'application/x-pdf' || file.type === 'application/acrobat' || file.type === 'pdf' || file.type === 'text/x-pdf' || file.type === 'application/x-download' || file.type === 'application/octet-stream';
  380. const isLt2M = file.size / 1024 / 1024 < 2;
  381. console.log(this.imgurl.length, '-0--------------------------------')
  382. if (this.imgurl.length > 4) {
  383. this.$message.warning('只能上传5张图片');
  384. return false;
  385. }
  386. if (!isJPG && !isPNG && !isWord && !isPdf) {
  387. this.$message.error('上传文件只能是 JPG、PNG、WORD、PDF 格式!');
  388. return false;
  389. }
  390. if (!isLt2M) {
  391. this.$message.error('上传缩略图大小不能超过 2MB!');
  392. return false;
  393. }
  394. const formData = new FormData();
  395. formData.append('file', file);
  396. this.$store.dispatch('pool/uploadFile', formData).then(res => {
  397. this.file = res.data.imgUrl;//提供表单地址
  398. this.fileType = res.data.fileType;
  399. this.oldFileName = res.data.oldFileName;
  400. this.form.file.push(res.data.imgUrl);//提供表单地址
  401. console.log(res.data.imgUrl, '00000')
  402. })
  403. // 阻止默认的上传行为
  404. return false;
  405. },
  406. deleteImage(index) { // 删除图片
  407. this.file.splice(index, 1);
  408. },
  409. //1.2 提交表单
  410. addToServe() {
  411. //先进行验证
  412. this.$refs.form.validate(valid => {
  413. console.log(this.form.validity, 'this.form.validity-----------------')
  414. if (valid) {
  415. if (this.form.validity) {
  416. this.form.validity = formatLocalDate(this.form.validity);
  417. }
  418. if (this.form.department_arr_id.length == 0) {
  419. this.form.department_id = 0;
  420. }
  421. if (this.form.city_arr_id.length == 0) {
  422. this.form.city_id = 0;
  423. }
  424. console.log(typeof this.form.city_arr_id, '---=-==-=')
  425. if (typeof this.form.city_arr_id == 'object') {
  426. this.form.city_id = this.form.city_arr_id.at(-1) || 0;
  427. this.form.city_arr_id = JSON.stringify(this.form.city_arr_id);
  428. }
  429. if (typeof this.form.department_arr_id == 'object') {
  430. this.form.department_id = this.form.department_arr_id.at(-1) || 0;
  431. this.form.department_arr_id = JSON.stringify(this.form.department_arr_id);
  432. }
  433. delete this.form.cat_arr_id;
  434. delete this.form.catid;
  435. this.form.file = this.file;
  436. console.log(this.form, 'this.form-----------------')
  437. if (this.userType == 10000) {
  438. this.form.status = 2
  439. } else {
  440. this.form.status = 1
  441. }
  442. this.$store.dispatch('news/addComplaint1', this.form).then(res => {
  443. if (res.code == 200) {
  444. //汇报结果
  445. this.$message({
  446. type: 'success',
  447. message: '已成功添加投诉举报!'
  448. });
  449. this.cleatForm();
  450. //返回列表页
  451. this.returnPage()
  452. } else {
  453. this.$message({
  454. type: 'error',
  455. message: "投诉举报发布失败,请稍后再试!"
  456. });
  457. }
  458. })
  459. }
  460. })
  461. },
  462. formatDate(date) {
  463. if (date instanceof Date) {
  464. return date.toISOString().slice(0, 19).replace('T', ' ');
  465. } else if (typeof date === 'string') {
  466. // 将 ISO 8601 格式的字符串转换为 MySQL 期望的格式
  467. const parsedDate = new Date(date);
  468. return parsedDate.toISOString().slice(0, 19).replace('T', ' ');
  469. } else {
  470. return date;
  471. }
  472. },
  473. //1.3 清理表单
  474. cleatForm() {
  475. },
  476. //提交表单 end ------------------------------------------------------------>
  477. //2.跳转操作 start ------------------------------------------------------------>
  478. returnPage() {
  479. this.$router.push({
  480. path: '/ncomplaintList',
  481. });
  482. },
  483. //跳转操作 end ------------------------------------------------------------>
  484. //3.回显操作 ------------------------------------------------------------>
  485. //3.1回显数据
  486. getMainData() {
  487. let data = {
  488. id: this.$route.query.id
  489. };
  490. this.$store.dispatch('news/getComplaintInfo', data).then(res => {
  491. console.log(res);
  492. this.form.name = res.data.name;
  493. // 回显导航池
  494. this.form.cat_arr_id = Array.isArray(res.data.cat_arr_id) ? res.data.cat_arr_id : JSON.parse(res.data.cat_arr_id);
  495. this.form.city_arr_id = Array.isArray(res.data.city_arr_id) ? res.data.city_arr_id : JSON.parse(res.data.city_arr_id);
  496. this.parentKey += 1; // 触发级联选择器重新加载
  497. this.loadCascaderPath(this.form.cat_arr_id); // 加载路径数据
  498. //回显推荐等级
  499. this.form.title = res.data.title;
  500. this.form.type = res.data.type;
  501. this.form.website_id = res.data.website_id;
  502. this.form.level = res.data.level;
  503. this.form.content = res.data.content;
  504. this.form.department_arr_id = Array.isArray(res.data.department_arr_id) ? res.data.department_arr_id : JSON.parse(res.data.department_arr_id);
  505. this.form.city_id = res.data.city_id;
  506. this.form.department_id = res.data.department_id;
  507. this.form.cat_id = res.data.cat_id;
  508. this.form.file = res.data.file;
  509. this.file = res.data.file;
  510. const filePath = res.data.file;
  511. const fileExtension = filePath.split('.').pop().toLowerCase();
  512. this.fileType = fileExtension; // 设置文件类型
  513. this.form.is_group = parseInt(res.data.is_group);
  514. this.form.group_name = res.data.group_name;
  515. this.form.want = res.data.want;
  516. this.form.start = res.data.start ? new Date(res.data.start) : null; // 处理时间格式
  517. this.form.re_user_ids = Array.isArray(res.data.re_user_ids) ? res.data.re_user_ids : JSON.parse(res.data.re_user_ids);
  518. })
  519. },
  520. async loadCascaderPath(path) {
  521. for (let i = 0; i < path.length; i++) {
  522. const parentId = path[i - 1] || 0; // 获取当前层级的父级ID
  523. const level = i; // 当前层级的索引
  524. // self.$store.dispatch('news/getWebsiteNavList', parames).then(res => {
  525. // if (res.data) {
  526. // const nodes = res.data.map(item => ({
  527. // value: item.category_id,
  528. // label: item.name,
  529. // leaf: level >= 3,
  530. // children: []
  531. // }))
  532. // resolve(nodes)
  533. await this.$store.dispatch('pool/categoryList', { pid: parentId })
  534. .then((res) => {
  535. const nodes = res.data.map(item => ({
  536. value: item.id,
  537. label: item.name,
  538. leaf: level >= 3, // 假设4层结构,设置叶子节点标记
  539. }));
  540. // 级联选择器加载数据
  541. if (level === path.length - 1) {
  542. this.form.cat_arr_id = path; // 确保最后一级路径正确设置
  543. this.parentKey += 1; // 强制刷新 cascader
  544. }
  545. });
  546. }
  547. },
  548. //1.3提交修改
  549. editToServe() {
  550. console.log(this.form)
  551. //添加要修改的id
  552. this.form.id = this.editId;
  553. //先进行验证
  554. this.$refs.form.validate(valid => {
  555. if (valid) {
  556. if (this.form.start) {
  557. this.form.start = formatLocalDate(this.form.start);
  558. }
  559. if (this.form.department_arr_id.length == 0) {
  560. this.form.department_id = 0;
  561. }
  562. if (this.form.city_arr_id.length == 0) {
  563. this.form.city_id = 0;
  564. }
  565. console.log(typeof this.form.city_arr_id, '---=-==-=')
  566. if (typeof this.form.city_arr_id == 'object') {
  567. this.form.city_id = this.form.city_arr_id.at(-1) || 0;
  568. this.form.city_arr_id = JSON.stringify(this.form.city_arr_id);
  569. }
  570. if (typeof this.form.department_arr_id == 'object') {
  571. this.form.department_id = this.form.department_arr_id.at(-1) || 0;
  572. this.form.department_arr_id = JSON.stringify(this.form.department_arr_id);
  573. }
  574. delete this.form.cat_arr_id;
  575. delete this.form.time;
  576. delete this.form.catid;
  577. this.form.file = this.file;
  578. console.log(this.form, 'this.form-----------------')
  579. if (this.userType == 10000) {
  580. this.form.status = 2
  581. } else {
  582. this.form.status = 1
  583. }
  584. this.$store.dispatch('news/updateComplaint', this.form).then(res => {
  585. if (res.code != 200) {
  586. this.$message.error("修改失败,请稍后再试!");
  587. } else {
  588. //汇报结果
  589. this.$message({
  590. type: 'success',
  591. message: '已成功编辑投诉举报!'
  592. });
  593. this.cleatForm();
  594. //返回列表页
  595. this.returnPage()
  596. }
  597. }).catch(() => {
  598. this.$message({
  599. type: 'info',
  600. message: '网络错误,请重试!'
  601. });
  602. })
  603. }
  604. })
  605. },
  606. //跳转操作 end ------------------------------------------------------------>
  607. //4.富文本编辑器 start ------------------------------------------------------------>
  608. //4.1 编辑器点击上传图片
  609. //4.2 图片粘贴上传
  610. // 处理从网页粘贴的图片 URL
  611. //富文本编辑器 end ------------------------------------------------------------>
  612. },
  613. watch: {
  614. //监听发布范围和行政职能的变化,获取行政人员
  615. 'form.city_arr_id': function (newVal, oldVal) {
  616. console.log(newVal, oldVal, 'newVal, oldVal')
  617. if (newVal.length > 0) {
  618. this.getDUser();
  619. }
  620. },
  621. 'form.department_arr_id': function (newVal, oldVal) {
  622. console.log(newVal, oldVal, 'newVal, oldVal')
  623. if (newVal.length > 0) {
  624. this.getDUser();
  625. }
  626. },
  627. '$route'(to, from) {
  628. console.log(from, '---------------------------------------');
  629. // 监听路由参数中的 id 变化,若变化则更新页面状态并获取数据
  630. if (to.query.id) {
  631. this.getMainData();
  632. }
  633. },
  634. },
  635. mounted() {
  636. //1.判断是新建还是回显
  637. if (this.$route.query.id != undefined) {
  638. this.editId = this.$route.query.id;
  639. this.editStatus = true;
  640. this.tableDivTitle = "编辑投诉举报";
  641. console.log("编辑投诉举报")
  642. this.getMainData();
  643. } else {
  644. this.editStatus = false;
  645. console.log("添加投诉举报!")
  646. }
  647. if (this.$route.query.read == 1) {
  648. this.readStatus = true;;
  649. } else {
  650. this.readStatus = false;
  651. }
  652. this.fetchWebsiteOptions();
  653. this.getUserInfo();
  654. // this.getDUser();
  655. //复制内容到富文本 start ------------------------------------------------------------>
  656. //复制富文本 end ------------------------------------------------------------>
  657. },
  658. };
  659. </script>
  660. <style scoped lang="less">
  661. //执行v-deep穿透scope选择器 start------------------------------------------------------------>*/
  662. ::v-deep .custom-form-item>.el-form-item__label {
  663. line-height: 140px !important;
  664. }
  665. ::v-deep .custom-textarea .el-textarea__inner {
  666. resize: none;
  667. /* 禁止用户拖拽调整大小 */
  668. }
  669. ::v-deep .custom-align-right .el-form-item__label {
  670. text-align: right;
  671. /* 设置标签文字右对齐 */
  672. }
  673. ::v-deep .el-select {
  674. width: 100%;
  675. /* 禁止用户拖拽调整大小 */
  676. }
  677. ::v-deep .el-input-group__prepend {
  678. color: black !important;
  679. }
  680. .formLabelFloatBox {
  681. margin-bottom: 10px;
  682. position: relative;
  683. .formLabeladdIcon {
  684. position: absolute;
  685. right: 45px;
  686. top: 5px;
  687. width: 38px;
  688. height: 24px;
  689. }
  690. .formLabelDelIcon {
  691. position: absolute;
  692. right: 5px;
  693. top: 5px;
  694. width: 38px;
  695. height: 24px;
  696. }
  697. }
  698. //执行v-deep穿透scope选择器 end------------------------------------------------------------>*/</style>