DisposeRubbishForm.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  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. processingUnits: [],
  226. taskName: '', //当前节点处理人节点名称
  227. fileList1: [],
  228. fileList2: [],
  229. fileList3: [],
  230. fileList4: [],
  231. nodeFlag: false,
  232. weighFlag: false, // 过磅管理员看到的信息
  233. inputForm: {
  234. programId: '',
  235. programIds: [],
  236. no: '',
  237. processingUnit: '',
  238. processingUnitName: '',
  239. clearUserId: '',
  240. clearUserName: '',
  241. clearUserMobile: '',
  242. remarks: '',
  243. status: '',
  244. workOverNoList: [],
  245. disposeType: '',
  246. rubbishStation: '',
  247. weight: '',
  248. transportMileage: '',
  249. subsidy: '',
  250. },
  251. rules: {
  252. 'processingUnit': [
  253. {
  254. required: true,
  255. message: '处理单位不能为空',
  256. trigger: ['blur', 'change']
  257. }
  258. ],
  259. }
  260. }
  261. },
  262. // 页面加载时执行
  263. async created() {
  264. EventBus.$on('refreshPhoto', this.refreshPhoto);
  265. if(!this.nodeFlag){
  266. let data = await disposeRubbishService.getMaxNo();
  267. if (data) {
  268. let newNo = parseInt(data, 10) + 1;
  269. this.inputForm.no = newNo;
  270. } else {
  271. // 获取当前年份
  272. let nowY = new Date().getFullYear();
  273. this.inputForm.no = nowY + '0001';
  274. }
  275. //获取垃圾站点信息
  276. let rubbishStation = await disposeRubbishService.getRubbishStation();
  277. this.inputForm.rubbishStation = rubbishStation;
  278. this.inputForm.processingUnit = this.userInfo.officeDTO.id
  279. this.inputForm.processingUnitName = this.userInfo.officeDTO.name
  280. // 不动态获取 根据当前登录人去查
  281. await overService.getUserInfoByOffId(this.userInfo.officeDTO.id)
  282. .then(data => {
  283. this.inputForm.clearUserId = data.id
  284. this.inputForm.clearUserName = data.name
  285. this.inputForm.clearUserMobile = data.mobile
  286. })
  287. .catch(e => {
  288. throw e;
  289. });
  290. }
  291. },
  292. props: {
  293. businessId: {
  294. type: String,
  295. default: ''
  296. },
  297. formReadOnly: {
  298. type: Boolean,
  299. default: false
  300. },
  301. status: {
  302. type: String,
  303. default: ''
  304. }
  305. },
  306. watch: {
  307. 'businessId': {
  308. handler (newVal) {
  309. if (this.businessId) {
  310. this.init(this.businessId)
  311. } else {
  312. this.$nextTick(() => {
  313. // this.$refs.inputForm.reset()
  314. })
  315. }
  316. },
  317. immediate: true,
  318. deep: false
  319. },
  320. },
  321. methods: {
  322. handleInput(field, value) {
  323. // Ensure value is a string and sanitize input
  324. value = value.toString();
  325. // Regular expression to match numbers with up to 2 decimal places and ensure positive value
  326. const regex = /^(?!.*[a-zA-Z])\-?\d+(\.\d{0,2})?$/;
  327. // Format the value based on regex
  328. const match = value.match(regex);
  329. console.log(match)
  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. console.log('查询当前信息', data);
  345. // 获取当前节点流程信息,并等待其执行完成
  346. const taskName = await taskService.getTaskNameByProcInsId(data.procInsId);
  347. this.taskName = taskName
  348. console.log('查询当前节点流程信息', taskName);
  349. // 根据任务名称处理逻辑
  350. if (this.isNotEmpty(taskName)) {
  351. if (taskName === '发起人重新申请' || this.isEmpty(taskName)) {
  352. this.nodeFlag = false;
  353. } else if (taskName === '过磅专员处理') {
  354. this.nodeFlag = true;
  355. this.weighFlag = true;
  356. }
  357. }
  358. // 恢复表单数据
  359. this.inputForm = this.recover(this.inputForm, data);
  360. // 处理文件列表
  361. if (data.fileList1) {
  362. this.fileList1 = data.fileList1.map(item => ({
  363. attachmentName: item.name,
  364. fileSize: item.size,
  365. url: item.temporaryUrl,
  366. type: item.type // 如果不需要,可以不写
  367. }));
  368. }
  369. if (data.fileList2) {
  370. this.fileList2 = data.fileList2.map(item => ({
  371. attachmentName: item.name,
  372. fileSize: item.size,
  373. url: item.temporaryUrl,
  374. type: item.type // 如果不需要,可以不写
  375. }));
  376. }
  377. if (data.fileList3) {
  378. this.fileList3 = data.fileList3.map(item => ({
  379. attachmentName: item.name,
  380. fileSize: item.size,
  381. url: item.temporaryUrl,
  382. type: item.type // 如果不需要,可以不写
  383. }));
  384. }
  385. }
  386. }
  387. ,
  388. async selectWorkOverChange(rows, index) {
  389. if (rows.length > 0) {
  390. rows.forEach((item, rowIndex) => {
  391. const exists = this.inputForm.programIds.includes(item.id);
  392. if(!exists){
  393. this.inputForm.programIds.push(item.id);
  394. if (rowIndex === 0) {
  395. let r = this.inputForm.workOverNoList[index];
  396. if (!r) {
  397. r = {};
  398. }
  399. r.no = item.no;
  400. this.$set(this.inputForm.workOverNoList, index, r);
  401. } else {
  402. let r = {
  403. no: item.no
  404. }
  405. this.inputForm.workOverNoList.push(r);
  406. }
  407. }
  408. });
  409. } else {
  410. const exists = this.inputForm.programIds.includes(item.id);
  411. if(!exists){
  412. let r = {
  413. no: item.no
  414. }
  415. if (!this.inputForm.detailInfoWorkOvers) {
  416. this.$set(this.inputForm, 'detailInfoWorkOvers', []);
  417. }
  418. this.$set(this.inputForm.detailInfoWorkOvers, index, r);
  419. this.inputForm.programIds.push(rows.id);
  420. }
  421. }
  422. //根据关联的询单id 查询处理前中后的信息进行填充照片
  423. const programIdString = this.inputForm.programIds.join(','); // 用逗号分隔
  424. await overService.getPhotoListByAttachmentAndFlag(programIdString,'before').then(data => {
  425. this.fileList1 = []
  426. data.forEach(
  427. (item) => {
  428. const newItem = {
  429. attachmentName: item.name,
  430. fileSize: item.size,
  431. url: item.temporaryUrl,
  432. type: item.type, // 如果不需要,可以不写
  433. };
  434. this.fileList1.push(newItem);
  435. }
  436. );
  437. }).catch(() => {
  438. reject('数据错误');
  439. });
  440. },
  441. addRow() {
  442. this.inputForm.workOverNoList.push({ recipientAgent: this.userInfo.name,
  443. recipientAgentId: this.userInfo.id, recipientOffice: this.userInfo.officeDTO.name });
  444. },
  445. // 显示 项目选择器
  446. showWorkOver(index) {
  447. this.$refs.workOverChoose.init(index);
  448. },
  449. // 显示 项目选择器
  450. disposeWorkOver(id) {
  451. console.log(this.inputForm.status)
  452. if(this.inputForm.status === '2'){
  453. uni.navigateTo({
  454. url: '/pages/edt/PatrolWorkOrderForm?id='+id
  455. })
  456. }else{
  457. this.toEdit(this.inputForm)
  458. }
  459. },
  460. //刷信photo获取对应的id
  461. refreshPhoto() {
  462. console.log('刷信photo获取对应的id',this.inputForm.id)
  463. disposeRubbishService.queryById(this.inputForm.id).then((data) => {
  464. if (data.fileList1) {
  465. this.fileList1 = []
  466. data.fileList1.forEach(
  467. (item) => {
  468. const newItem = {
  469. attachmentName: item.name,
  470. fileSize: item.size,
  471. url: item.temporaryUrl,
  472. type: item.type, // 如果不需要,可以不写
  473. };
  474. this.fileList1.push(newItem);
  475. }
  476. );
  477. }
  478. if (data.fileList2) {
  479. this.fileList2 = []
  480. data.fileList2.forEach(
  481. (item) => {
  482. const newItem = {
  483. attachmentName: item.name,
  484. fileSize: item.size,
  485. url: item.temporaryUrl,
  486. type: item.type, // 如果不需要,可以不写
  487. };
  488. this.fileList2.push(newItem);
  489. }
  490. );
  491. }
  492. if (data.fileList3) {
  493. this.fileList3 = []
  494. data.fileList3.forEach(
  495. (item) => {
  496. const newItem = {
  497. attachmentName: item.name,
  498. fileSize: item.size,
  499. url: item.temporaryUrl,
  500. type: item.type, // 如果不需要,可以不写
  501. };
  502. this.fileList3.push(newItem);
  503. }
  504. );
  505. }
  506. })
  507. },
  508. removeRow(index) {
  509. console.log('index',index)
  510. // 点击删除按钮时,从表格中移除指定行
  511. this.inputForm.workOverNoList.splice(index, 1);
  512. },
  513. formatDate(date) {
  514. const dateNew = new Date(date); // 将日期字符串转换为 Date 对象
  515. const year = dateNew.getFullYear();
  516. const month = (dateNew.getMonth() + 1).toString().padStart(2, '0');
  517. const day = dateNew.getDate().toString().padStart(2, '0');
  518. return `${year}-${month}-${day}`;
  519. },
  520. isEmpty(value) {
  521. let result = false;
  522. if (value == null || value == undefined) {
  523. result = true;
  524. }
  525. if (typeof value == 'string' && (value.replace(/\s+/g, "") == "" || value == "")) {
  526. result = true;
  527. }
  528. if (typeof value == "object" && value instanceof Array && value.length === 0) {
  529. result = true;
  530. }
  531. return result;
  532. },
  533. isNotEmpty (value) {
  534. return !this.isEmpty(value)
  535. },
  536. /**
  537. * 判断是否为空
  538. */
  539. isNull(val) {
  540. if (val instanceof Array) {
  541. if (val.length === 0) return true;
  542. } else if (val instanceof Object) {
  543. if (JSON.stringify(val) === "{}") return true;
  544. } else {
  545. if (
  546. val === "null" ||
  547. val == null ||
  548. val === "undefined" ||
  549. val === undefined ||
  550. val === ""
  551. )
  552. return true;
  553. return false;
  554. }
  555. return false;
  556. },
  557. formatDateNew(date) {
  558. const year = date.getFullYear();
  559. const month = (date.getMonth() + 1).toString().padStart(2, '0');
  560. const day = date.getDate().toString().padStart(2, '0');
  561. const hours = date.getHours().toString().padStart(2, '0');
  562. const minutes = date.getMinutes().toString().padStart(2, '0');
  563. const seconds = date.getSeconds().toString().padStart(2, '0');
  564. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  565. },
  566. saveForm(callback) {
  567. this.isProcessing = true; // 显示遮罩层
  568. return new Promise((resolve, reject) => {
  569. // 表单规则验证
  570. // ...
  571. let errors = [];
  572. if(!this.inputForm.disposeType){
  573. errors.push("请选择处理方式")
  574. }
  575. if(this.inputForm.programId && !this.inputForm.programIds){
  576. this.inputForm.programIds = []
  577. let fruitsArray = this.inputForm.programId.split(',');
  578. this.inputForm.programIds = fruitsArray
  579. }
  580. if(!this.inputForm.programId && this.inputForm.programIds){
  581. const programIdString = this.inputForm.programIds.join(','); // 用逗号分隔
  582. this.inputForm.programId = programIdString
  583. }
  584. if(this.inputForm.programIds.length == 0){
  585. errors.push("请选择巡视工单")
  586. }
  587. if(this.weighFlag){
  588. if(!this.inputForm.weight){
  589. errors.push("请填写重量")
  590. }
  591. if(!this.inputForm.transportMileage){
  592. errors.push("请填写运输里程")
  593. }
  594. if(!this.inputForm.subsidy){
  595. errors.push("请填写补贴金额")
  596. }
  597. }
  598. if (errors.length > 0) {
  599. // 存在错误,显示提示信息
  600. errors.forEach(error => {
  601. this.isProcessing = false; // 显示遮罩层
  602. uni.showToast({
  603. title: error,
  604. icon: 'none',
  605. duration: 2000
  606. });
  607. });
  608. reject('Form validation failed');
  609. } else {
  610. // 所有验证通过,执行保存操作
  611. this.$refs.inputForm.validate().then(() => {
  612. uni.showLoading();
  613. if(this.weighFlag){
  614. this.inputForm.status = '5'
  615. }else{
  616. if(this.inputForm.disposeType === '1'){
  617. this.inputForm.status = '2'
  618. }else if(this.inputForm.disposeType === '2'){
  619. if(this.taskName){
  620. this.inputForm.status = '5'
  621. }else{
  622. this.inputForm.status = '2'
  623. }
  624. }else{
  625. this.inputForm.status = '2'
  626. }
  627. }
  628. this.inputForm.fileList4 = this.fileList4
  629. disposeRubbishService.save(this.inputForm).then(data => {
  630. console.log('提交成功拉')
  631. uni.showToast({
  632. title: "提交成功",
  633. icon: "success",
  634. duration: 1000 // 提示持续时间为1秒(1000毫秒)
  635. });
  636. // 延迟1秒后再跳转到上一页
  637. setTimeout(() => {
  638. this.isProcessing = false; // 显示遮罩层
  639. callback(data.businessTable, data.businessId,this.inputForm.disposeType);
  640. uni.navigateBack({
  641. delta: 1
  642. });
  643. }, 1000);
  644. resolve('Form saved successfully');
  645. }).catch(error => {
  646. reject('Save operation failed');
  647. });
  648. }).catch(() => {
  649. reject('Form validation failed');
  650. });
  651. }
  652. });
  653. },
  654. // 删除图片
  655. deletePic(event) {
  656. this[`fileList${event.name}`].splice(event.index, 1)
  657. },
  658. // 新增图片
  659. async afterRead(event) {
  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. },
  681. uploadFilePromise(url, index) {
  682. console.log($auth.getUserToken())
  683. return new Promise((resolve, reject) => {
  684. let a = uni.uploadFile({
  685. url: 'http://localhost:8000/app/file/webUpload/fileUpload', // 仅为示例,非真实的接口地址
  686. filePath: url,
  687. name: 'file',
  688. formData: {
  689. user: this.$store.state.user.userInfo
  690. },
  691. header: {
  692. 'token': $auth.getUserToken(),
  693. },
  694. success: (res) => {
  695. // this.fileList1[index].url = url
  696. setTimeout(() => {
  697. const dataObj = JSON.parse(res.data);
  698. const url = dataObj.url;
  699. resolve(url);
  700. }, 1000);
  701. },
  702. fail: (err) => {
  703. console.error('Upload failed:', err);
  704. }
  705. });
  706. })
  707. },
  708. getUserInfoByOffId(){
  709. // 根据组织ID 获取 该村的 村支书
  710. overService.getUserInfoByOffId(this.inputForm.processingUnit)
  711. .then(data => {
  712. this.inputForm.clearUserId = data.id
  713. this.inputForm.clearUserName = data.name
  714. this.inputForm.clearUserMobile = data.mobile
  715. })
  716. .catch(e => {
  717. throw e;
  718. });
  719. }
  720. }
  721. }
  722. </script>
  723. <style>
  724. .form-section {
  725. padding: 10px 15px;
  726. margin-bottom: 10px;
  727. background-color: #ffffff;
  728. border-radius: 5px;
  729. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  730. }
  731. .u-page__upload-item {
  732. margin-top: 10px;
  733. }
  734. .button-container {
  735. margin-top: 20px;
  736. text-align: center;
  737. }
  738. .cu-form-group .title {
  739. min-width: 100px;
  740. }
  741. /* 遮罩层样式 */
  742. .mask {
  743. position: fixed;
  744. top: 0;
  745. left: 0;
  746. width: 100%;
  747. height: 100%;
  748. background-color: rgba(0, 0, 0, 0.05); /* 半透明遮罩 */
  749. z-index: 9999; /* 确保遮罩层在最顶层 */
  750. }
  751. </style>