DisposeRubbishForm.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831
  1. <template>
  2. <view>
  3. <cu-custom :backUrl="'/pages/index/index?id=apps'" :isBack="true" bgColor="bg-gradual-blue">
  4. <block slot="content">建筑垃圾清运处理</block>
  5. </cu-custom>
  6. <!-- First Section: 巡视工单 to 联系方式 -->
  7. <view class="form-section">
  8. <!-- 遮罩层 -->
  9. <view v-if="isProcessing" class="mask"></view>
  10. <u--form :model="inputForm" labelWidth="100px" class="u-form" labelPosition="left" :rules="rules" ref="inputForm" v-if="!nodeFlag">
  11. <u-form-item label="清运编号" prop="no">
  12. <u--input v-model="inputForm.no" :disabled="true" placeholder="工单编号" clearable></u--input>
  13. </u-form-item>
  14. <u-form-item label="所属单位" prop="processingUnitName" :required="true" v-if="disFlag">
  15. <u--input v-model="inputForm.processingUnitName" :disabled="true" placeholder="所属单位" clearable></u--input>
  16. </u-form-item>
  17. <u-form-item label="清运专员" prop="clearUserName">
  18. <u--input v-model="inputForm.clearUserName" :disabled="true" placeholder="清运专员" clearable></u--input>
  19. </u-form-item>
  20. <u-form-item label="联系方式" prop="clearUserMobile">
  21. <u--input v-model="inputForm.clearUserMobile" :disabled="true" placeholder="联系方式" clearable></u--input>
  22. </u-form-item>
  23. <u-form-item label="处理方式" prop="disposeType" :required="true">
  24. <jp-picker v-model="inputForm.disposeType" rangeKey="label" rangeValue="value" :range="[
  25. { label: '转运调剂处理', value: '1' },
  26. { label: '自行处理', value: '2' },
  27. ]" ></jp-picker>
  28. </u-form-item>
  29. <u-form-item label="垃圾站点" prop="rubbishStation">
  30. <u--input v-model="inputForm.rubbishStation" :disabled="true" placeholder="垃圾站点" clearable></u--input>
  31. </u-form-item>
  32. <template>
  33. <div>
  34. <u-form-item
  35. v-for="(item, index_workOver) in inputForm.workOverNoList"
  36. :key="index_workOver"
  37. :label="`巡视工单 ${index_workOver + 1}`"
  38. :required="true"
  39. :prop="'workOverNoList[' + index_workOver + '].no'"
  40. >
  41. <u--input v-model="inputForm.workOverNoList[index_workOver].no" placeholder="请选择巡视工单编号" @focus="showWorkOver(index_workOver)" clearable></u--input>
  42. <u-button type="error" style="width: 20%" text="删除" @click="removeRow(index_workOver)"></u-button>
  43. </u-form-item>
  44. </div>
  45. </template>
  46. <u-form-item label="" >
  47. <u-button style="width: 100%" type="primary" @click="addRow()" plain>新增基本信息</u-button>
  48. </u-form-item>
  49. </u--form>
  50. <u--form :model="inputForm" labelWidth="100px" class="u-form" labelPosition="left" :rules="rules" ref="inputForm" v-if="nodeFlag">
  51. <u-form-item label="清运编号" prop="no">
  52. <u--input v-model="inputForm.no" :disabled="true" placeholder="工单编号" clearable></u--input>
  53. </u-form-item>
  54. <u-form-item label="所属单位" prop="processingUnitName" :required="true" v-if="disFlag">
  55. <u--input v-model="inputForm.processingUnitName" :disabled="true" placeholder="所属单位" clearable></u--input>
  56. </u-form-item>
  57. <u-form-item label="清运专员" prop="clearUserName">
  58. <u--input v-model="inputForm.clearUserName" :disabled="true" placeholder="清运专员" clearable></u--input>
  59. </u-form-item>
  60. <u-form-item label="联系方式" prop="clearUserMobile">
  61. <u--input v-model="inputForm.clearUserMobile" :disabled="true" placeholder="联系方式" clearable></u--input>
  62. </u-form-item>
  63. <u-form-item label="处理方式" prop="disposeType" :required="true" >
  64. <jp-picker v-model="inputForm.disposeType" rangeKey="label" :disabled="true" rangeValue="value" :range="[
  65. { label: '转运调剂处理', value: '1' },
  66. { label: '自行处理', value: '2' },
  67. ]" ></jp-picker>
  68. </u-form-item>
  69. <u-form-item label="垃圾站点" prop="rubbishStation">
  70. <u--input v-model="inputForm.rubbishStation" :disabled="true" placeholder="垃圾站点" clearable></u--input>
  71. </u-form-item>
  72. <template>
  73. <div>
  74. <u-form-item
  75. v-for="(item, index_workOver) in inputForm.workOverNoList"
  76. :key="index_workOver"
  77. :label="`巡视工单 ${index_workOver + 1}`"
  78. :required="true"
  79. :prop="'workOverNoList[' + index_workOver + '].no'"
  80. >
  81. <u--input
  82. v-model="inputForm.workOverNoList[index_workOver].no"
  83. :disabled="true"
  84. placeholder="请选择巡视工单编号">
  85. </u--input>
  86. <u-button type="primary" style="width: 20%" text="处理" @click="disposeWorkOver(inputForm.workOverNoList[index_workOver].id)" v-if="!weighFlag"></u-button>
  87. </u-form-item>
  88. </div>
  89. </template>
  90. </u--form>
  91. </view>
  92. <!-- Second Section: 上传图片 -->
  93. <view class="form-section">
  94. <text class="u-demo-block__title">清理前照片</text>
  95. <view class="u-page__upload-item">
  96. <u-upload
  97. :disabled="true"
  98. :fileList="fileList1"
  99. @afterRead="afterRead"
  100. name="1"
  101. multiple
  102. :maxCount="10"
  103. ></u-upload>
  104. </view>
  105. </view>
  106. <!-- Second Section: 上传图片 -->
  107. <view class="form-section">
  108. <text class="u-demo-block__title">清理中照片</text>
  109. <view class="u-page__upload-item">
  110. <u-upload
  111. :disabled="true"
  112. :fileList="fileList2"
  113. @afterRead="afterRead"
  114. name="2"
  115. multiple
  116. :maxCount="10"
  117. ></u-upload>
  118. </view>
  119. </view>
  120. <!-- Second Section: 上传图片 -->
  121. <view class="form-section">
  122. <text class="u-demo-block__title">清理后照片</text>
  123. <view class="u-page__upload-item">
  124. <u-upload
  125. :disabled="true"
  126. :fileList="fileList3"
  127. @afterRead="afterRead"
  128. name="3"
  129. multiple
  130. :maxCount="10"
  131. ></u-upload>
  132. </view>
  133. </view>
  134. <!-- Third Section: 备注 -->
  135. <view class="form-section" v-if="!nodeFlag">
  136. <u--form :model="inputForm" labelWidth="100px" class="u-form" labelPosition="left" :rules="rules" ref="inputForm" >
  137. <u-form-item label="备注" borderBottom prop="remarks">
  138. <u--textarea placeholder='请填写备注' :maxlength="500" v-model="inputForm.remarks"></u--textarea>
  139. </u-form-item>
  140. <!--<view class="button-container">
  141. <u-button
  142. text="提交"
  143. size="large"
  144. type="primary"
  145. @click="saveForm"
  146. ></u-button>
  147. </view>-->
  148. </u--form>
  149. </view>
  150. <!-- Third Section: 备注 -->
  151. <view class="form-section" v-if="nodeFlag || weighFlag">
  152. <u--form :model="inputForm" labelWidth="100px" class="u-form" labelPosition="left" :rules="rules" ref="inputForm" >
  153. <u-form-item label="备注" borderBottom prop="remarks">
  154. <u--textarea placeholder='请填写备注' :disabled="true" :maxlength="500" v-model="inputForm.remarks"></u--textarea>
  155. </u-form-item>
  156. </u--form>
  157. </view>
  158. <view class="form-section" v-if="weighFlag">
  159. <span style="color: #4396fd;">现场信息登记</span>
  160. <u--form :model="inputForm" labelWidth="100px" class="u-form" labelPosition="left" :rules="rules" ref="inputForm">
  161. <u-form-item label="重量(t)" prop="weight" :required="true">
  162. <u--input
  163. v-model="inputForm.weight"
  164. @input="handleInput('weight', $event)"
  165. placeholder="重量"
  166. clearable
  167. ></u--input>
  168. </u-form-item>
  169. <u-form-item label="运输里程(km)" prop="transportMileage" :required="true">
  170. <u--input
  171. v-model="inputForm.transportMileage"
  172. @input="handleInput('transportMileage', $event)"
  173. placeholder="运输里程"
  174. clearable
  175. ></u--input>
  176. </u-form-item>
  177. <u-form-item label="补贴(元)" prop="subsidy" :required="true">
  178. <u--input
  179. v-model="inputForm.subsidy"
  180. @input="handleInput('subsidy', $event)"
  181. placeholder="补贴"
  182. clearable
  183. ></u--input>
  184. </u-form-item>
  185. </u--form>
  186. </view>
  187. <!-- Second Section: 上传图片 -->
  188. <view class="form-section" v-if="weighFlag">
  189. <text style="color: black">过磅现场照片</text>
  190. <view class="u-page__upload-item" >
  191. <text class="u-demo-block__title">照片上传</text>
  192. <u-upload
  193. :fileList="fileList4"
  194. @afterRead="afterRead"
  195. @delete="deletePic"
  196. name="4"
  197. multiple
  198. :maxCount="10"
  199. ></u-upload>
  200. </view>
  201. </view>
  202. <WorkOverChoose ref="workOverChoose" @input="selectWorkOverChange" title="报告项目选择"/>
  203. </view>
  204. </template>
  205. <script>
  206. import disposeRubbishService from '@/api/garbageClearance/disposeRubbishService'
  207. import overService from '@/api/garbageClearance/overService'
  208. import WorkOverChoose from './WorkOverChoose'
  209. import taskService from "@/api/flowable/taskService"
  210. import {mapState, mapMutations, mapActions} from 'vuex'
  211. import * as $auth from "../../common/auth";
  212. import { EventBus } from '@/store/eventBus.js';
  213. export default {
  214. components: {
  215. WorkOverChoose,
  216. },
  217. computed: mapState({
  218. userInfo: (state) => state.user.userInfo,
  219. avatar: (state) => state.user.avatar
  220. }),
  221. data () {
  222. return {
  223. disFlag: true, // 启用动态获取处理单位则设置为false
  224. isProcessing: false, // 遮罩层
  225. uploadFlag: true, // 上传判定值
  226. processingUnits: [],
  227. taskName: '', //当前节点处理人节点名称
  228. fileList1: [],
  229. fileList2: [],
  230. fileList3: [],
  231. fileList4: [],
  232. nodeFlag: false,
  233. weighFlag: false, // 过磅管理员看到的信息
  234. inputForm: {
  235. programId: '',
  236. programIds: [],
  237. no: '',
  238. processingUnit: '',
  239. processingUnitName: '',
  240. clearUserId: '',
  241. clearUserName: '',
  242. clearUserMobile: '',
  243. remarks: '',
  244. status: '',
  245. workOverNoList: [],
  246. disposeType: '',
  247. rubbishStation: '',
  248. weight: '',
  249. transportMileage: '',
  250. subsidy: '',
  251. },
  252. rules: {
  253. 'processingUnit': [
  254. {
  255. required: true,
  256. message: '处理单位不能为空',
  257. trigger: ['blur', 'change']
  258. }
  259. ],
  260. }
  261. }
  262. },
  263. // 页面加载时执行
  264. async created() {
  265. EventBus.$on('refreshPhoto', this.refreshPhoto);
  266. if(!this.nodeFlag){
  267. let data = await disposeRubbishService.getMaxNo();
  268. if (data) {
  269. let newNo = parseInt(data, 10) + 1;
  270. this.inputForm.no = newNo;
  271. } else {
  272. // 获取当前年份
  273. let nowY = new Date().getFullYear();
  274. this.inputForm.no = nowY + '0001';
  275. }
  276. //获取垃圾站点信息
  277. let rubbishStation = await disposeRubbishService.getRubbishStation();
  278. this.inputForm.rubbishStation = rubbishStation;
  279. this.inputForm.processingUnit = this.userInfo.officeDTO.id
  280. this.inputForm.processingUnitName = this.userInfo.officeDTO.name
  281. // 不动态获取 根据当前登录人去查
  282. await overService.getUserInfoByOffId(this.userInfo.officeDTO.id)
  283. .then(data => {
  284. this.inputForm.clearUserId = data.id
  285. this.inputForm.clearUserName = data.name
  286. this.inputForm.clearUserMobile = data.mobile
  287. })
  288. .catch(e => {
  289. throw e;
  290. });
  291. }
  292. },
  293. props: {
  294. businessId: {
  295. type: String,
  296. default: ''
  297. },
  298. formReadOnly: {
  299. type: Boolean,
  300. default: false
  301. },
  302. status: {
  303. type: String,
  304. default: ''
  305. }
  306. },
  307. watch: {
  308. 'businessId': {
  309. handler (newVal) {
  310. if (this.businessId) {
  311. this.init(this.businessId)
  312. } else {
  313. this.$nextTick(() => {
  314. // this.$refs.inputForm.reset()
  315. })
  316. }
  317. },
  318. immediate: true,
  319. deep: false
  320. },
  321. },
  322. methods: {
  323. handleInput(field, value) {
  324. // Ensure value is a string and sanitize input
  325. value = value.toString();
  326. // Regular expression to match numbers with up to 2 decimal places and ensure positive value
  327. const regex = /^(?!.*[a-zA-Z])\-?\d+(\.\d{0,2})?$/;
  328. // Format the value based on regex
  329. const match = value.match(regex);
  330. let formattedValue = (match && match[0]) || '';
  331. // Ensure the value is positive
  332. if (parseFloat(formattedValue) < 0) {
  333. formattedValue = '';
  334. }
  335. // Update input form based on the field
  336. this.inputForm[field] = formattedValue;
  337. },
  338. async init(id) {
  339. this.nodeFlag = true;
  340. this.inputForm.id = id;
  341. if (id) {
  342. // 使用 await 等待查询结果
  343. const data = await disposeRubbishService.queryById(id);
  344. // 获取当前节点流程信息,并等待其执行完成
  345. const taskName = await taskService.getTaskNameByProcInsId(data.procInsId);
  346. this.taskName = taskName
  347. // 根据任务名称处理逻辑
  348. if (this.isNotEmpty(taskName)) {
  349. if (taskName === '发起人重新申请' || this.isEmpty(taskName)) {
  350. this.nodeFlag = false;
  351. } else if (taskName === '过磅专员处理') {
  352. this.nodeFlag = true;
  353. this.weighFlag = true;
  354. }
  355. }
  356. // 恢复表单数据
  357. this.inputForm = this.recover(this.inputForm, data);
  358. // 处理文件列表
  359. if (data.fileList1) {
  360. this.fileList1 = data.fileList1.map(item => ({
  361. attachmentName: item.name,
  362. fileSize: item.size,
  363. url: item.temporaryUrl,
  364. type: item.type // 如果不需要,可以不写
  365. }));
  366. }
  367. if (data.fileList2) {
  368. this.fileList2 = data.fileList2.map(item => ({
  369. attachmentName: item.name,
  370. fileSize: item.size,
  371. url: item.temporaryUrl,
  372. type: item.type // 如果不需要,可以不写
  373. }));
  374. }
  375. if (data.fileList3) {
  376. this.fileList3 = data.fileList3.map(item => ({
  377. attachmentName: item.name,
  378. fileSize: item.size,
  379. url: item.temporaryUrl,
  380. type: item.type // 如果不需要,可以不写
  381. }));
  382. }
  383. }
  384. }
  385. ,
  386. async selectWorkOverChange(rows, index) {
  387. if (rows.length > 0) {
  388. rows.forEach((item, rowIndex) => {
  389. const exists = this.inputForm.programIds.includes(item.id);
  390. if(!exists){
  391. this.inputForm.programIds.push(item.id);
  392. if (rowIndex === 0) {
  393. let r = this.inputForm.workOverNoList[index];
  394. if (!r) {
  395. r = {};
  396. }
  397. r.no = item.no;
  398. this.$set(this.inputForm.workOverNoList, index, r);
  399. } else {
  400. let r = {
  401. no: item.no
  402. }
  403. this.inputForm.workOverNoList.push(r);
  404. }
  405. }
  406. });
  407. } else {
  408. const exists = this.inputForm.programIds.includes(item.id);
  409. if(!exists){
  410. let r = {
  411. no: item.no
  412. }
  413. if (!this.inputForm.detailInfoWorkOvers) {
  414. this.$set(this.inputForm, 'detailInfoWorkOvers', []);
  415. }
  416. this.$set(this.inputForm.detailInfoWorkOvers, index, r);
  417. this.inputForm.programIds.push(rows.id);
  418. }
  419. }
  420. //根据关联的询单id 查询处理前中后的信息进行填充照片
  421. const programIdString = this.inputForm.programIds.join(','); // 用逗号分隔
  422. await overService.getPhotoListByAttachmentAndFlag(programIdString,'before').then(data => {
  423. this.fileList1 = []
  424. data.forEach(
  425. (item) => {
  426. const newItem = {
  427. attachmentName: item.name,
  428. fileSize: item.size,
  429. url: item.temporaryUrl,
  430. type: item.type, // 如果不需要,可以不写
  431. };
  432. this.fileList1.push(newItem);
  433. }
  434. );
  435. }).catch(() => {
  436. reject('数据错误');
  437. });
  438. },
  439. addRow() {
  440. this.inputForm.workOverNoList.push({ recipientAgent: this.userInfo.name,
  441. recipientAgentId: this.userInfo.id, recipientOffice: this.userInfo.officeDTO.name });
  442. },
  443. // 显示 项目选择器
  444. showWorkOver(index) {
  445. this.$refs.workOverChoose.init(index);
  446. },
  447. // 显示 项目选择器
  448. disposeWorkOver(id) {
  449. if(this.inputForm.status === '2'){
  450. uni.navigateTo({
  451. url: '/pages/edt/PatrolWorkOrderForm?id='+id
  452. })
  453. }else{
  454. this.toEdit(this.inputForm)
  455. }
  456. },
  457. //刷信photo获取对应的id
  458. refreshPhoto() {
  459. disposeRubbishService.queryById(this.inputForm.id).then((data) => {
  460. if (data.fileList1) {
  461. this.fileList1 = []
  462. data.fileList1.forEach(
  463. (item) => {
  464. const newItem = {
  465. attachmentName: item.name,
  466. fileSize: item.size,
  467. url: item.temporaryUrl,
  468. type: item.type, // 如果不需要,可以不写
  469. };
  470. this.fileList1.push(newItem);
  471. }
  472. );
  473. }
  474. if (data.fileList2) {
  475. this.fileList2 = []
  476. data.fileList2.forEach(
  477. (item) => {
  478. const newItem = {
  479. attachmentName: item.name,
  480. fileSize: item.size,
  481. url: item.temporaryUrl,
  482. type: item.type, // 如果不需要,可以不写
  483. };
  484. this.fileList2.push(newItem);
  485. }
  486. );
  487. }
  488. if (data.fileList3) {
  489. this.fileList3 = []
  490. data.fileList3.forEach(
  491. (item) => {
  492. const newItem = {
  493. attachmentName: item.name,
  494. fileSize: item.size,
  495. url: item.temporaryUrl,
  496. type: item.type, // 如果不需要,可以不写
  497. };
  498. this.fileList3.push(newItem);
  499. }
  500. );
  501. }
  502. })
  503. },
  504. removeRow(index) {
  505. // 点击删除按钮时,从表格中移除指定行
  506. this.inputForm.workOverNoList.splice(index, 1);
  507. },
  508. formatDate(date) {
  509. const dateNew = new Date(date); // 将日期字符串转换为 Date 对象
  510. const year = dateNew.getFullYear();
  511. const month = (dateNew.getMonth() + 1).toString().padStart(2, '0');
  512. const day = dateNew.getDate().toString().padStart(2, '0');
  513. return `${year}-${month}-${day}`;
  514. },
  515. isEmpty(value) {
  516. let result = false;
  517. if (value == null || value == undefined) {
  518. result = true;
  519. }
  520. if (typeof value == 'string' && (value.replace(/\s+/g, "") == "" || value == "")) {
  521. result = true;
  522. }
  523. if (typeof value == "object" && value instanceof Array && value.length === 0) {
  524. result = true;
  525. }
  526. return result;
  527. },
  528. isNotEmpty (value) {
  529. return !this.isEmpty(value)
  530. },
  531. /**
  532. * 判断是否为空
  533. */
  534. isNull(val) {
  535. if (val instanceof Array) {
  536. if (val.length === 0) return true;
  537. } else if (val instanceof Object) {
  538. if (JSON.stringify(val) === "{}") return true;
  539. } else {
  540. if (
  541. val === "null" ||
  542. val == null ||
  543. val === "undefined" ||
  544. val === undefined ||
  545. val === ""
  546. )
  547. return true;
  548. return false;
  549. }
  550. return false;
  551. },
  552. formatDateNew(date) {
  553. const year = date.getFullYear();
  554. const month = (date.getMonth() + 1).toString().padStart(2, '0');
  555. const day = date.getDate().toString().padStart(2, '0');
  556. const hours = date.getHours().toString().padStart(2, '0');
  557. const minutes = date.getMinutes().toString().padStart(2, '0');
  558. const seconds = date.getSeconds().toString().padStart(2, '0');
  559. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  560. },
  561. saveForm(callback) {
  562. this.isProcessing = true; // 显示遮罩层
  563. return new Promise((resolve, reject) => {
  564. // 表单规则验证
  565. // ...
  566. let errors = [];
  567. if(!this.uploadFlag){
  568. errors.push("图片未上传完成,请等待上传完后在提交")
  569. }
  570. if(!this.inputForm.disposeType){
  571. errors.push("请选择处理方式")
  572. }
  573. if(this.inputForm.programId && !this.inputForm.programIds){
  574. this.inputForm.programIds = []
  575. let fruitsArray = this.inputForm.programId.split(',');
  576. this.inputForm.programIds = fruitsArray
  577. }
  578. if(!this.inputForm.programId && this.inputForm.programIds){
  579. const programIdString = this.inputForm.programIds.join(','); // 用逗号分隔
  580. this.inputForm.programId = programIdString
  581. }
  582. if(this.inputForm.programIds.length == 0){
  583. errors.push("请选择巡视工单")
  584. }
  585. if(this.weighFlag){
  586. if(!this.inputForm.weight){
  587. errors.push("请填写重量")
  588. }
  589. if(!this.inputForm.transportMileage){
  590. errors.push("请填写运输里程")
  591. }
  592. if(!this.inputForm.subsidy){
  593. errors.push("请填写补贴金额")
  594. }
  595. }
  596. if (errors.length > 0) {
  597. // 存在错误,显示提示信息
  598. errors.forEach(error => {
  599. this.isProcessing = false; // 显示遮罩层
  600. uni.showToast({
  601. title: error,
  602. icon: 'none',
  603. duration: 2000
  604. });
  605. });
  606. this.isProcessing = false;
  607. reject('Form validation failed');
  608. } else {
  609. // 所有验证通过,执行保存操作
  610. this.$refs.inputForm.validate().then(() => {
  611. uni.showLoading();
  612. if(this.weighFlag){
  613. this.inputForm.status = '5'
  614. }else{
  615. if(this.inputForm.disposeType === '1'){
  616. this.inputForm.status = '2'
  617. }else if(this.inputForm.disposeType === '2'){
  618. if(this.taskName){
  619. this.inputForm.status = '5'
  620. }else{
  621. this.inputForm.status = '2'
  622. }
  623. }else{
  624. this.inputForm.status = '2'
  625. }
  626. }
  627. this.inputForm.fileList4 = this.fileList4
  628. disposeRubbishService.save(this.inputForm).then(data => {
  629. uni.showToast({
  630. title: "提交成功",
  631. icon: "success",
  632. duration: 1000 // 提示持续时间为1秒(1000毫秒)
  633. });
  634. // 延迟1秒后再跳转到上一页
  635. setTimeout(() => {
  636. this.isProcessing = false; // 显示遮罩层
  637. callback(data.businessTable, data.businessId,this.inputForm.disposeType);
  638. uni.navigateBack({
  639. delta: 1
  640. });
  641. }, 1000);
  642. resolve('Form saved successfully');
  643. }).catch(error => {
  644. reject('Save operation failed');
  645. });
  646. }).catch(() => {
  647. reject('Form validation failed');
  648. });
  649. }
  650. });
  651. },
  652. // 删除图片
  653. deletePic(event) {
  654. this[`fileList${event.name}`].splice(event.index, 1)
  655. },
  656. // 新增图片
  657. async afterRead(event) {
  658. try {
  659. this.uploadFlag = false
  660. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  661. let lists = [].concat(event.file)
  662. let fileListLen = this[`fileList${event.name}`].length
  663. lists.map((item) => {
  664. this[`fileList${event.name}`].push({
  665. ...item,
  666. status: 'uploading',
  667. message: '上传中'
  668. })
  669. })
  670. for (let i = 0; i < lists.length; i++) {
  671. const result = await this.uploadFilePromise(lists[i].url, fileListLen)
  672. let item = this[`fileList${event.name}`][fileListLen]
  673. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  674. status: 'success',
  675. message: '',
  676. url: result
  677. }))
  678. fileListLen++
  679. }
  680. this.uploadFlag = true
  681. } catch (error) {
  682. console.error('上传失败:', error);
  683. } finally {
  684. this.uploadFlag = true
  685. }
  686. },
  687. uploadFilePromise(url, index) {
  688. return new Promise((resolve, reject) => {
  689. let a = uni.uploadFile({
  690. url: 'http://localhost:8000/app/file/webUpload/fileUpload', // 仅为示例,非真实的接口地址
  691. filePath: url,
  692. name: 'file',
  693. formData: {
  694. user: this.$store.state.user.userInfo
  695. },
  696. header: {
  697. 'token': $auth.getUserToken(),
  698. },
  699. success: (res) => {
  700. // this.fileList1[index].url = url
  701. setTimeout(() => {
  702. const dataObj = JSON.parse(res.data);
  703. const url = dataObj.url;
  704. resolve(url);
  705. }, 1000);
  706. },
  707. fail: (err) => {
  708. console.error('Upload failed:', err);
  709. }
  710. });
  711. })
  712. },
  713. getUserInfoByOffId(){
  714. // 根据组织ID 获取 该村的 村支书
  715. overService.getUserInfoByOffId(this.inputForm.processingUnit)
  716. .then(data => {
  717. this.inputForm.clearUserId = data.id
  718. this.inputForm.clearUserName = data.name
  719. this.inputForm.clearUserMobile = data.mobile
  720. })
  721. .catch(e => {
  722. throw e;
  723. });
  724. }
  725. }
  726. }
  727. </script>
  728. <style>
  729. .form-section {
  730. padding: 10px 15px;
  731. margin-bottom: 10px;
  732. background-color: #ffffff;
  733. border-radius: 5px;
  734. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  735. }
  736. .u-page__upload-item {
  737. margin-top: 10px;
  738. }
  739. .button-container {
  740. margin-top: 20px;
  741. text-align: center;
  742. }
  743. .cu-form-group .title {
  744. min-width: 100px;
  745. }
  746. /* 遮罩层样式 */
  747. .mask {
  748. position: fixed;
  749. top: 0;
  750. left: 0;
  751. width: 100%;
  752. height: 100%;
  753. background-color: rgba(0, 0, 0, 0.05); /* 半透明遮罩 */
  754. z-index: 9999; /* 确保遮罩层在最顶层 */
  755. }
  756. </style>