index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886
  1. <template>
  2. <!--补卡审批申请-->
  3. <view class="card-replacement">
  4. <view class="main">
  5. <view class="header">
  6. <view
  7. v-for="(item, idx) in detailInfo.checkNoTime"
  8. :key="idx"
  9. >
  10. {{ item }} 缺卡
  11. </view>
  12. <view>{{ detailInfo.applyNum }}</view>
  13. </view>
  14. <u--form
  15. labelPosition="left"
  16. :model="fmData"
  17. :rules="rules"
  18. ref="uForm"
  19. labelWidth="auto"
  20. class="dynamic-form"
  21. >
  22. <!--不可新增fmItem-->
  23. <view class="def-box">
  24. <u-form-item
  25. :key="item.id"
  26. v-for="item in defList"
  27. :label="item.name"
  28. :prop="item.valueKey"
  29. :required="!!item.isRequire"
  30. borderBottom
  31. >
  32. <!-- text -->
  33. <c-input
  34. v-if="item.type === typeKeys.text"
  35. :placeholder="item.tips"
  36. class="input-text"
  37. type="text"
  38. v-model="fmData[item.valueKey]"
  39. border="none"
  40. ></c-input>
  41. <!-- number -->
  42. <c-input-number
  43. v-if="item.type === typeKeys.number"
  44. class="input-text"
  45. v-model="fmData[item.valueKey]"
  46. :placeholder="item.tips"
  47. border="none"
  48. ></c-input-number>
  49. <!-- phoneNum -->
  50. <c-input
  51. v-if="item.type === typeKeys.phoneNum"
  52. class="input-text"
  53. type="number"
  54. :placeholder="item.tips"
  55. maxlength="11"
  56. v-model="fmData[item.valueKey]"
  57. border="none"
  58. ></c-input>
  59. <!-- select -->
  60. <view
  61. class="align-right"
  62. v-if="item.type === typeKeys.select"
  63. >
  64. <pickerSelect
  65. v-model="fmData[item.valueKey]"
  66. :placeholder="item.tips || '请选择'"
  67. :columns="item.variables"
  68. ></pickerSelect>
  69. </view>
  70. <!-- radio -->
  71. <u-radio-group
  72. v-if="item.type === typeKeys.radio"
  73. v-model="fmData[item.valueKey]"
  74. >
  75. <u-radio
  76. :customStyle="{
  77. marginBottom: '8px',
  78. marginTop: '8px',
  79. marginRight: '8px',
  80. }"
  81. v-for="(item, index) in item.variables"
  82. :key="index"
  83. :label="item.name"
  84. :name="item.name"
  85. >
  86. </u-radio>
  87. </u-radio-group>
  88. <!-- checkbox -->
  89. <u-checkbox-group
  90. v-if="item.type === typeKeys.checkbox"
  91. v-model="fmData[item.valueKey]"
  92. >
  93. <u-checkbox
  94. :customStyle="{
  95. marginBottom: '8px',
  96. marginTop: '8px',
  97. marginRight: '8px',
  98. }"
  99. v-for="(item, index) in item.variables"
  100. :key="index"
  101. :label="item.name"
  102. :name="item.name"
  103. >
  104. </u-checkbox>
  105. </u-checkbox-group>
  106. <!-- upload -->
  107. <view
  108. v-if="item.type === typeKeys.upload"
  109. class="align-right"
  110. >
  111. <c-upload
  112. :accept="item.accept"
  113. :maxCount="item.uploadNum"
  114. v-model="fmData[item.valueKey]"
  115. >
  116. </c-upload>
  117. </view>
  118. <!-- textarea -->
  119. <u--textarea
  120. v-if="item.type === typeKeys.textarea"
  121. v-model="fmData[item.valueKey]"
  122. :placeholder="item.tips"
  123. ></u--textarea>
  124. <!-- time -->
  125. <view
  126. class="align-right"
  127. v-if="item.type === typeKeys.time"
  128. >
  129. <dateSelect
  130. mode="time"
  131. v-model="fmData[item.valueKey]"
  132. @change="dateChange($event, item)"
  133. :placeholder="item.tips || '请选择'"
  134. ></dateSelect>
  135. </view>
  136. <!-- date -->
  137. <view
  138. class="align-right"
  139. v-if="item.type === typeKeys.date"
  140. >
  141. <dateSelect
  142. mode="date"
  143. @change="dateChange($event, item)"
  144. v-model="fmData[item.valueKey]"
  145. :placeholder="item.tips || '请选择'"
  146. ></dateSelect>
  147. </view>
  148. <!-- datetime -->
  149. <view
  150. class="align-right"
  151. :class="{ 'place-color': !fmData[item.valueKey] }"
  152. v-if="item.type === typeKeys.datetime"
  153. >
  154. <uni-datetime-picker
  155. v-model="fmData[item.valueKey]"
  156. :border="false"
  157. type="datetime"
  158. @change="dateChange($event, item)"
  159. />
  160. </view>
  161. <!-- datetimerange -->
  162. <view
  163. class="align-right"
  164. :class="{ 'place-color': !fmData[item.valueKey] }"
  165. v-if="item.type === typeKeys.datetimerange"
  166. >
  167. <uni-datetime-picker
  168. v-model="fmData[item.valueKey]"
  169. :border="false"
  170. type="datetimerange"
  171. @change="dateChange($event, item)"
  172. />
  173. </view>
  174. </u-form-item>
  175. </view>
  176. <!--可新增fmItem-->
  177. <view class="add-group" :key="i" v-for="(arr, i) in addList">
  178. <view class="add-item-header">
  179. <view class="hd-left-title">序列</view>
  180. <c-button @click="delArr(i)" type="text">删除</c-button>
  181. </view>
  182. <u-form-item
  183. :label="item.name"
  184. :prop="item.valueKey"
  185. :required="!!item.isRequire"
  186. :key="item.id"
  187. v-for="item in arr"
  188. borderBottom
  189. >
  190. <!-- text -->
  191. <c-input
  192. v-if="item.type === typeKeys.text"
  193. :placeholder="item.tips"
  194. class="input-text"
  195. type="text"
  196. v-model="fmData[item.valueKey]"
  197. border="none"
  198. ></c-input>
  199. <!-- number -->
  200. <c-input
  201. v-if="item.type === typeKeys.number"
  202. class="input-text"
  203. type="number"
  204. v-model="fmData[item.valueKey]"
  205. border="none"
  206. ></c-input>
  207. <!-- phoneNum -->
  208. <c-input
  209. v-if="item.type === typeKeys.phoneNum"
  210. class="input-text"
  211. type="number"
  212. :placeholder="item.tips"
  213. maxlength="11"
  214. v-model="fmData[item.valueKey]"
  215. border="none"
  216. ></c-input>
  217. <!-- select -->
  218. <view
  219. class="align-right"
  220. v-if="item.type === typeKeys.select"
  221. >
  222. <pickerSelect
  223. v-model="fmData[item.valueKey]"
  224. :placeholder="item.tips || '请选择'"
  225. :columns="item.variables"
  226. ></pickerSelect>
  227. </view>
  228. <!-- radio -->
  229. <u-radio-group
  230. v-if="item.type === typeKeys.radio"
  231. v-model="fmData[item.valueKey]"
  232. >
  233. <u-radio
  234. :customStyle="{
  235. marginBottom: '8px',
  236. marginTop: '8px',
  237. marginRight: '8px',
  238. }"
  239. v-for="(item, index) in item.variables"
  240. :key="index"
  241. :label="item.name"
  242. :name="item.name"
  243. >
  244. </u-radio>
  245. </u-radio-group>
  246. <!-- checkbox -->
  247. <u-checkbox-group
  248. v-if="item.type === typeKeys.checkbox"
  249. v-model="fmData[item.valueKey]"
  250. >
  251. <u-checkbox
  252. :customStyle="{
  253. marginBottom: '8px',
  254. marginTop: '8px',
  255. marginRight: '8px',
  256. }"
  257. v-for="(item, index) in item.variables"
  258. :key="index"
  259. :label="item.name"
  260. :name="item.name"
  261. >
  262. </u-checkbox>
  263. </u-checkbox-group>
  264. <!-- upload -->
  265. <view
  266. v-if="item.type === typeKeys.upload"
  267. class="align-right"
  268. >
  269. <c-upload
  270. :accept="item.accept"
  271. :maxCount="item.uploadNum"
  272. v-model="fmData[item.valueKey]"
  273. >
  274. </c-upload>
  275. </view>
  276. <!-- textarea -->
  277. <u--textarea
  278. v-if="item.type === typeKeys.textarea"
  279. v-model="fmData[item.valueKey]"
  280. :placeholder="item.tips"
  281. ></u--textarea>
  282. <!-- time -->
  283. <view
  284. class="align-right"
  285. v-if="item.type === typeKeys.time"
  286. >
  287. <dateSelect
  288. mode="time"
  289. v-model="fmData[item.valueKey]"
  290. @change="dateChange($event, item, arr)"
  291. :placeholder="item.tips || '请选择'"
  292. ></dateSelect>
  293. </view>
  294. <!-- date -->
  295. <view
  296. class="align-right"
  297. v-if="item.type === typeKeys.date"
  298. >
  299. <dateSelect
  300. mode="date"
  301. @change="dateChange($event, item, arr)"
  302. v-model="fmData[item.valueKey]"
  303. :placeholder="item.tips || '请选择'"
  304. ></dateSelect>
  305. </view>
  306. <!-- datetime -->
  307. <view
  308. class="align-right"
  309. :class="{
  310. 'place-color': !fmData[item.valueKey],
  311. }"
  312. v-if="item.type === typeKeys.datetime"
  313. >
  314. <uni-datetime-picker
  315. v-model="fmData[item.valueKey]"
  316. :border="false"
  317. type="datetime"
  318. @change="dateChange($event, item, arr)"
  319. />
  320. </view>
  321. <!-- datetimerange -->
  322. <view
  323. class="align-right"
  324. :class="{
  325. 'place-color': !fmData[item.valueKey],
  326. }"
  327. v-if="item.type === typeKeys.datetimerange"
  328. >
  329. <uni-datetime-picker
  330. v-model="fmData[item.valueKey]"
  331. :border="false"
  332. type="datetimerange"
  333. @change="dateChange($event, item, arr)"
  334. />
  335. </view>
  336. </u-form-item>
  337. <view
  338. class="add-item-footer"
  339. v-if="i === addList.length - 1"
  340. >
  341. <c-button size="mini" type="primary" @click="handleAdd">
  342. <u-icon name="plus" color="#fff" size="12"></u-icon>
  343. <text style="margin-left: 4px">增加</text>
  344. </c-button>
  345. </view>
  346. </view>
  347. </u--form>
  348. <!--流程图-->
  349. <footer-process
  350. :condList="condList"
  351. :infoDto="infoDto"
  352. ></footer-process>
  353. </view>
  354. <view class="footer">
  355. <c-button
  356. :disabled="disabled"
  357. @click="handleSubmit"
  358. type="primary"
  359. >
  360. 提交
  361. </c-button>
  362. </view>
  363. </view>
  364. </template>
  365. <script>
  366. import { typeKeys } from '@/pages/approval/types';
  367. import pickerSelect from '@/pages/approval/com/pickerSelect.vue';
  368. import dateSelect from '@/pages/approval/com/dateSelect.vue';
  369. import { process, start, priview } from '@/api/approval/index.js';
  370. import FooterProcess from '@/pages/approval/approvalApply/footerProcess.vue';
  371. export default {
  372. name: 'cardReplacement',
  373. props: {
  374. processType: String, // 流程类型
  375. },
  376. components: {
  377. FooterProcess,
  378. pickerSelect,
  379. dateSelect,
  380. },
  381. data() {
  382. return {
  383. condList: [], // 作为条件的项
  384. orderId: '',
  385. detailInfo: {
  386. checkNoTime: [], // tips
  387. elementBos: [],
  388. },
  389. infoDto: [], // 流程图
  390. typeKeys,
  391. fmData: {},
  392. rules: {},
  393. defList: [], // 默认项(不可新增)
  394. addList: [], // 新增项 二维数组[[]]
  395. };
  396. },
  397. computed: {
  398. disabled() {
  399. return (
  400. this.detailInfo.checkNoTime.length === 0 &&
  401. this.processType === '0' // 0补卡审批
  402. );
  403. },
  404. },
  405. created() {
  406. this.getForms();
  407. },
  408. methods: {
  409. watchList() {
  410. // 监听作为条件的项
  411. const { condList } = this;
  412. if (condList.length === 0) {
  413. return;
  414. }
  415. // 筛选出所有必填的 作为条件项
  416. const reqList = condList.filter((item) => item.isRequire === 1);
  417. condList.forEach((item) => {
  418. const { valueKey } = item;
  419. let val = this.getDefaultVal(item); // 获取默认数据
  420. Object.defineProperty(this.fmData, valueKey, {
  421. get: () => {
  422. return val;
  423. },
  424. set: (newVal) => {
  425. if (val === newVal) return;
  426. val = newVal;
  427. const isErr = reqList.some((it) => {
  428. const k = it.valueKey;
  429. return !this.fmData[k] && this.fmData[k] !== 0;
  430. }); // false:已全部填写完整
  431. const { text, number } = typeKeys;
  432. if (![text, number].includes(item.type)) {
  433. this.$forceUpdate();
  434. }
  435. if (!isErr) {
  436. uni.$u.debounce(this.getFlowChart, 300); // 防抖
  437. }
  438. },
  439. });
  440. });
  441. },
  442. async getFlowChart() {
  443. const params = {};
  444. this.condList.forEach((item) => {
  445. const key = item.valueKey;
  446. params[key] = this.fmData[key];
  447. });
  448. const { data } = await priview(this.orderId, params);
  449. this.infoDto = data;
  450. },
  451. delArr(idx) {
  452. uni.showModal({
  453. content: '确认删除吗?',
  454. success: (e) => {
  455. if (e.confirm) {
  456. this.addList.splice(idx, 1);
  457. }
  458. },
  459. });
  460. },
  461. handleAdd() {
  462. const firstArr = this.addList[0];
  463. const rdm = Math.random().toString(36).slice(-6);
  464. const newArr = firstArr.map((item) => {
  465. const valueKey = `${item.name}${rdm}`;
  466. this.setFmRule(item, valueKey); // 设置fm某一项的校验规则
  467. return {
  468. ...item,
  469. valueKey,
  470. };
  471. });
  472. this.addList.push(newArr);
  473. },
  474. getDefaultVal(item) {
  475. // 获取默认数据类型
  476. return item.type === typeKeys.checkbox ? [] : undefined;
  477. },
  478. setDefList(data) {
  479. // 不是新增项
  480. data.forEach((item) => {
  481. const valueKey = item.name;
  482. this.setFmRule(item, valueKey); // 设置fm某一项的校验规则
  483. this.$set(this.fmData, valueKey, this.getDefaultVal(item)); // 确保数据响应式
  484. const variables = item.variables
  485. ? JSON.parse(item.variables)
  486. : []; // 处理variables为array
  487. this.defList.push({ ...item, variables, valueKey });
  488. });
  489. },
  490. setFmRule(item, valueKey) {
  491. // 设置fm某一项的校验规则
  492. if (item.isRequire !== 1) {
  493. // ====1必填
  494. return;
  495. }
  496. const { checkbox, upload, number } = this.typeKeys;
  497. const ruleType = {
  498. [checkbox]: 'array',
  499. [upload]: 'array',
  500. [number]: 'number',
  501. };
  502. const rule = [
  503. {
  504. type: ruleType[item.type] || 'string',
  505. required: true,
  506. message: '该项必填',
  507. trigger: ['change'],
  508. },
  509. ];
  510. // 必填
  511. this.$set(this.rules, valueKey, rule);
  512. },
  513. setAddList(data) {
  514. if (!data || data.length === 0) {
  515. return;
  516. }
  517. // 可新增项
  518. const newData = data.map((item) => {
  519. const valueKey = `${item.name}0`;
  520. this.setFmRule(item, valueKey); // 设置fm某一项的校验规则
  521. this.$set(this.fmData, valueKey, this.getDefaultVal(item)); // 确保数据响应式
  522. const variables = item.variables
  523. ? JSON.parse(item.variables)
  524. : []; // 处理variables为array
  525. return { ...item, variables, valueKey };
  526. });
  527. this.addList = [newData];
  528. },
  529. /**
  530. * 日期时间范围选择 计算得到小时
  531. */
  532. dateTimeRangeChange(dtKey, calcItem) {
  533. const [startDate, endDate] = this.fmData[dtKey];
  534. const sumMilli = +new Date(endDate) - +new Date(startDate);
  535. const h = sumMilli / 1000 / 60 / 60;
  536. this.setCount(h, calcItem.countkey); // 为计算结果赋值
  537. },
  538. getCalcItem(addRrr) {
  539. const list = addRrr || this.defList;
  540. const calcItem = {
  541. countkey: '', // 总和的key
  542. dtKey: '', // 日期时间范围选择器的key 是否计算
  543. computeType: [], // 减数/被减数的类型
  544. rduKey: '', // 1减数的key
  545. miuKey: '', // 0被减数的key
  546. };
  547. list.forEach((item) => {
  548. const { valueKey } = item;
  549. if (item.isCompute === 1) {
  550. // 1是 0否 int
  551. // 日期时间范围选择器 是否计算 1是 0否 int
  552. calcItem.dtKey = valueKey;
  553. }
  554. if (item.isCount === 1) {
  555. // 减数
  556. calcItem.rduKey = valueKey;
  557. calcItem.computeType.push(item.type);
  558. }
  559. if (item.isCount === 0) {
  560. // 0被减数的key
  561. calcItem.miuKey = valueKey;
  562. calcItem.computeType.push(item.type);
  563. }
  564. if (item.getCount === 1) {
  565. // 获取计算结果 1是 0否 int
  566. calcItem.countkey = valueKey;
  567. }
  568. });
  569. return calcItem;
  570. },
  571. dateChange(val, item, addArr) {
  572. const calcItem = this.getCalcItem(addArr);
  573. const { rduKey, miuKey, countkey, computeType, dtKey } =
  574. calcItem;
  575. const [rType, mType] = computeType || [];
  576. if (
  577. countkey &&
  578. dtKey &&
  579. item.type === this.typeKeys.datetimerange
  580. ) {
  581. // (计算结果key、总和key)存在
  582. this.dateTimeRangeChange(dtKey, calcItem); // 单独处理日期时间范围选择器
  583. return;
  584. }
  585. if (
  586. rduKey && // 减数key存在
  587. miuKey && // 被减数key 存在
  588. countkey && // 计算结果key存在
  589. computeType.length === 2 && // 减数和被减数的类型都有
  590. rType === mType && // 减数和被减数的类型相同
  591. this.fmData[rduKey] && // 表单中数据选了减数
  592. this.fmData[miuKey] && //表单中数据选了被减数
  593. [rduKey, miuKey].includes(item.valueKey) // 是 减数或者被减数
  594. ) {
  595. this.calcType(rType, calcItem);
  596. }
  597. },
  598. /**
  599. * 根据类型进不同函数
  600. * @param {type} 选择器的类型
  601. */
  602. calcType(type, calcItem) {
  603. // 根据类型进不同函数
  604. const { time, date, datetime } = this.typeKeys;
  605. if (type === time) {
  606. // 类型为time 得到小时
  607. this.timeCalc(calcItem);
  608. return;
  609. }
  610. if (type === date) {
  611. // 类型为date 日期-计算得到天
  612. this.dateCalc(calcItem);
  613. return;
  614. }
  615. if (type === datetime) {
  616. // 类型为datetime 日期-计算得到小时
  617. this.dateTimeCalc(calcItem);
  618. return;
  619. }
  620. },
  621. dateTimeCalc(calcItem) {
  622. // dateTime计算
  623. const { rduKey, miuKey, countkey } = calcItem;
  624. const rduDateTime = this.fmData[rduKey]; //减数
  625. const miuDateTime = this.fmData[miuKey]; //被减数
  626. const sumMilli =
  627. +new Date(rduDateTime) - +new Date(miuDateTime);
  628. const h = sumMilli / 1000 / 60 / 60;
  629. this.setCount(h, countkey); // 为计算结果赋值
  630. },
  631. /**
  632. * 日期yyyy-mm-dd 计算得到天
  633. */
  634. dateCalc(calcItem) {
  635. // 日期yyyy-mm-dd 计算得到天
  636. // 相差: 天 参数--day
  637. const { rduKey, miuKey, countkey } = calcItem;
  638. const rduDate = this.fmData[rduKey]; //减数
  639. const miuDate = this.fmData[miuKey]; //被减数
  640. const sumMilli = +new Date(rduDate) - +new Date(miuDate);
  641. const day = sumMilli / 1000 / 60 / 60 / 24;
  642. this.setCount(day, countkey); // 为计算结果赋值
  643. },
  644. setCount(num, countkey) {
  645. const res = Number(num).toFixed(2) * 1;
  646. this.fmData[countkey] = res; // 计算结果赋值
  647. if (this.processType === '2') {
  648. // 类型是出差
  649. const dayKey = this.defList.find(
  650. (item) => item.name === '出差天数'
  651. )?.valueKey; // 出差天数 fmkey
  652. const cKeys = this.addList.map((arr) => {
  653. return arr.find((item) => item.getCount === 1)?.valueKey; // 总和
  654. }); // 每个行程的时长的key
  655. if (dayKey && cKeys?.length) {
  656. let totalDays = 0;
  657. cKeys.forEach((key) => {
  658. totalDays += this.fmData[key];
  659. });
  660. this.fmData[dayKey] = totalDays;
  661. }
  662. }
  663. },
  664. /**
  665. * time计算
  666. */
  667. timeCalc(calcItem) {
  668. const { rduKey, miuKey, countkey } = calcItem;
  669. // time计算
  670. const [rduH, rudM] = this.fmData[rduKey].split(':'); //减数
  671. const [miuH, miuM] = this.fmData[miuKey].split(':'); //被减数
  672. const rduTotal = rduH * 60 + Number(rudM); // 总分钟-减数
  673. const miuTotal = miuH * 60 + Number(miuM); // 总分钟-被减数
  674. const minuteSum = rduTotal - miuTotal; // 得到
  675. const num = minuteSum / 60;
  676. this.setCount(num, countkey); // 为计算结果赋值
  677. },
  678. async handleSubmit() {
  679. await this.$refs.uForm.validate();
  680. try {
  681. uni.$c.loading();
  682. const { orderId, resultId } = this.detailInfo || {};
  683. const { fmData, defList, addList } = this;
  684. const data = {
  685. orderId,
  686. resultId,
  687. variables: { fmData, defList, addList },
  688. };
  689. await start(data);
  690. uni.hideLoading();
  691. await uni.$c.toast({
  692. icon: 'success',
  693. title: '提交成功',
  694. });
  695. // uni.switchTab({ url: '/pages/home/index' }); // 去首页
  696. this.getForms(); // 刷新
  697. } catch (e) {
  698. uni.hideLoading();
  699. throw new Error(e);
  700. }
  701. },
  702. async getForms() {
  703. try {
  704. this.defList = []; // 默认项(不可新增)
  705. this.addList = []; // 新增项
  706. uni.$c.loading();
  707. const { data } = await process({ type: this.processType });
  708. uni.hideLoading();
  709. this.orderId = data.orderId;
  710. const newData = {
  711. ...data,
  712. elementBos: data.elementBos || [], //表单
  713. checkNoTime: data.checkNoTime || [], // 缺卡arr
  714. };
  715. //新增项
  716. const addList = newData.elementBos.filter(
  717. (item) => item.isAdd === 1
  718. );
  719. this.setAddList(addList);
  720. // 不是新增项
  721. const defList = newData.elementBos.filter(
  722. (item) => item.isAdd !== 1
  723. );
  724. this.setDefList(defList);
  725. // todo 查询流程图业务暂不需要判断addList (新增项)
  726. const condList = this.defList.filter(
  727. (item) => item.isCondition === 1
  728. ); // 作为条件的项--全部有值后查询流程图
  729. this.condList = condList || [];
  730. if (this.condList.length === 0) {
  731. this.getFlowChart(); // 如果没有作为条件项--查询流程图
  732. }
  733. this.watchList(); // 监听作为条件的项
  734. this.detailInfo = newData;
  735. } catch (e) {
  736. uni.hideLoading();
  737. throw e;
  738. }
  739. },
  740. },
  741. };
  742. </script>
  743. <style scoped lang="scss">
  744. .card-replacement {
  745. display: flex;
  746. flex-direction: column;
  747. padding: 30rpx;
  748. flex: 1;
  749. overflow: hidden;
  750. .main {
  751. flex: 1;
  752. overflow-y: auto;
  753. .header {
  754. font-size: 12px;
  755. color: #989ca5;
  756. margin-bottom: 20rpx;
  757. }
  758. .dynamic-form {
  759. .def-box {
  760. background-color: #fff;
  761. padding: 0 20rpx;
  762. border-radius: 6px;
  763. }
  764. .add-group {
  765. background-color: #fff;
  766. padding: 20rpx;
  767. border-radius: 6px;
  768. margin-top: 20rpx;
  769. .add-item-header {
  770. display: flex;
  771. justify-content: space-between;
  772. background: rgba(67, 111, 246, 0.12);
  773. line-height: 60rpx;
  774. border-radius: 4px;
  775. padding: 0 6px;
  776. .hd-left-title {
  777. font-size: 14px;
  778. color: $u-tips-color;
  779. }
  780. }
  781. .add-item-footer {
  782. margin-top: 20rpx;
  783. .c-button {
  784. width: 70px;
  785. border-radius: 13px;
  786. }
  787. }
  788. }
  789. .uni-date {
  790. width: initial;
  791. flex: inherit;
  792. }
  793. .place-color {
  794. /deep/.uni-date__x-input {
  795. color: #c0c4cc;
  796. }
  797. }
  798. .align-right {
  799. width: 100%;
  800. display: flex;
  801. justify-content: flex-end;
  802. flex-wrap: wrap;
  803. }
  804. .u-radio-group {
  805. flex-wrap: wrap;
  806. justify-content: flex-end;
  807. width: 100%;
  808. }
  809. .u-checkbox-group {
  810. flex-wrap: wrap;
  811. justify-content: flex-end;
  812. width: 100%;
  813. }
  814. .input-text {
  815. /deep/ .uni-input-input {
  816. text-align: right;
  817. }
  818. /deep/ .uni-input-placeholder {
  819. text-align: right;
  820. }
  821. }
  822. /deep/ .u-form-item__body {
  823. display: flex;
  824. justify-content: space-between;
  825. .u-form-item__body__right {
  826. margin-left: 20rpx;
  827. }
  828. }
  829. }
  830. }
  831. .footer {
  832. margin-top: 20rpx;
  833. margin-bottom: 20rpx;
  834. }
  835. }
  836. </style>