addNcomplaint.vue 28 KB

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