addNcomplaint.vue 28 KB

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