app-diy-form.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837
  1. <template>
  2. <view class="app-diy-form" :style="{
  3. paddingTop: `${marginTop}rpx`,
  4. paddingBottom: `${marginBottom}rpx`,
  5. backgroundColor: `${marginColor}`
  6. }">
  7. <view class="title" v-if="title !== '' && title !== null">{{title}}</view>
  8. <!--<view style="border: 1rpx solid #ff3455">
  9. <view v-for="(item, index) in myList" :key="index">{{item.name}}:{{item.value}}</view>
  10. </view>-->
  11. <view :style="{
  12. backgroundColor: backgroundColor,
  13. backgroundImage: backgroundImage ? `url(${backgroundImage})` : `none`,
  14. backgroundPosition: backgroundPosition,
  15. backgroundSize: `${backgroundWidth}% ${backgroundHeight}%`,
  16. backgroundRepeat: backgroundRepeat,
  17. paddingTop: `${paddingTop}rpx`,
  18. paddingBottom: `${paddingBottom}rpx`,
  19. }">
  20. <view class="list"
  21. :class="[showItemBorder?'item-border':'', showAllItems?'show-all':'show-first',labelFs28?'label-fs-28':'']">
  22. <template v-for="(item, index) in myList">
  23. <view :key="index" v-if="item.key=='text'"
  24. class="item"
  25. :class="[itemClass, index===0 ? `is-first-item` : ``,]"
  26. :style="{
  27. 'padding': `0 ${itemPaddingX}rpx`,
  28. 'margin-bottom': `${itemMarginY}rpx`,
  29. }">
  30. <view v-if="labelPosition !== 'inset'" class="box-grow-0 cross-top label">
  31. <image v-if="showRequiredIcon && (item.is_required == 1 || item.is_required == '1')"
  32. class="required-icon"
  33. src="/static/image/icon/required.png"></image>
  34. <view class="name-key"
  35. :class="[`text-align-${labelTextAlign}`]"
  36. :style="{
  37. 'color': labelColor
  38. }">{{item.name}}
  39. </view>
  40. </view>
  41. <view class="box-grow-1">
  42. <app-input v-model="item.value"
  43. :default-value="item.default"
  44. :background-color="inputBackground"
  45. @input="textInput"
  46. :color="inputTextColor"
  47. :placeholder="labelPosition === 'inset' ? item.name:item.hint"
  48. :height="`${itemHeight}`"
  49. :border="showInputBorder"
  50. :radius="inputRadius"
  51. :placeholder-style="[`color:${inputPlaceholderColor}`]"
  52. :padding-left="getInputPaddingLeft"
  53. :border-color="inputBorderColor"></app-input>
  54. </view>
  55. </view>
  56. <view :key="index" v-if="item.key=='textarea'"
  57. class="item"
  58. :class="[itemClass, index===0 ? `is-first-item` : ``,]"
  59. :style="{
  60. 'padding': `0 ${itemPaddingX}rpx`,
  61. 'margin-bottom': `${itemMarginY}rpx`,
  62. }">
  63. <view v-if="labelPosition !== 'inset'" class="box-grow-0 cross-top label">
  64. <image v-if="showRequiredIcon && (item.is_required == 1 || item.is_required == '1')"
  65. class="required-icon"
  66. src="/static/image/icon/required.png"></image>
  67. <view class="name-key"
  68. :class="[`text-align-${labelTextAlign}`]"
  69. :style="{
  70. 'color': labelColor
  71. }">{{item.name}}
  72. </view>
  73. </view>
  74. <view class="box-grow-1">
  75. <app-textarea v-model="item.value"
  76. :default-value="item.value"
  77. :background="inputBackground"
  78. @input="textInput"
  79. :color="inputTextColor"
  80. :placeholder="labelPosition === 'inset' ? item.name:item.hint"
  81. :show-border="showInputBorder"
  82. :border-radius="inputRadius"
  83. :padding-x="getInputPaddingLeft"
  84. :placeholder-style="[`color:${inputPlaceholderColor}`]"
  85. :border-color="inputBorderColor"></app-textarea>
  86. </view>
  87. </view>
  88. <view :key="index" v-if="item.key=='date'"
  89. class="item"
  90. :class="[itemClass, index===0 ? `is-first-item` : ``,]"
  91. :style="{
  92. 'padding': `0 ${itemPaddingX}rpx`,
  93. 'margin-bottom': `${itemMarginY}rpx`,
  94. }">
  95. <view class="box-grow-0 cross-top label">
  96. <image v-if="showRequiredIcon && (item.is_required == 1 || item.is_required == '1')"
  97. class="required-icon"
  98. src="/static/image/icon/required.png"></image>
  99. <view class="name-key"
  100. :class="[`text-align-${labelTextAlign}`]"
  101. :style="{
  102. 'color': labelColor
  103. }">{{item.name}}
  104. </view>
  105. </view>
  106. <view class="box-grow-1">
  107. <app-datetime-picker v-model="item.value"
  108. @change="datetimeChange"
  109. :text="item.value||''"
  110. :sign="index"
  111. :show-border="showInputBorder"
  112. :background="inputBackground"
  113. :height="itemHeight"
  114. :radius="inputRadius"
  115. :default-value="item.default"
  116. :text-color="inputTextColor"
  117. :text-position="getDateTimeTextPosition"
  118. :border-color="inputBorderColor"
  119. :start="item.min ? item.min : ''"
  120. :padding="datePadding"
  121. :end="item.max ? item.max : ''">
  122. <!-- #ifdef MP-TOUTIAO -->
  123. {{item.value||''}}
  124. <!-- #endif -->
  125. </app-datetime-picker>
  126. </view>
  127. </view>
  128. <view :key="index" v-if="item.key=='time'"
  129. class="item"
  130. :class="[itemClass, index===0 ? `is-first-item` : ``,]"
  131. :style="{
  132. 'padding': `0 ${itemPaddingX}rpx`,
  133. 'margin-bottom': `${itemMarginY}rpx`,
  134. }">
  135. <view class="box-grow-0 cross-top label">
  136. <image v-if="showRequiredIcon && (item.is_required == 1 || item.is_required == '1')"
  137. class="required-icon"
  138. src="/static/image/icon/required.png"></image>
  139. <view class="name-key"
  140. :class="[`text-align-${labelTextAlign}`]"
  141. :style="{
  142. 'color': labelColor
  143. }">{{item.name}}
  144. </view>
  145. </view>
  146. <view class="box-grow-1">
  147. <app-datetime-picker v-model="item.value"
  148. @change="datetimeChange"
  149. mode="time"
  150. :text="item.value||''"
  151. :sign="index"
  152. :default-value="item.default"
  153. :show-border="showInputBorder"
  154. :background="inputBackground"
  155. :height="itemHeight"
  156. :radius="inputRadius"
  157. :text-color="inputTextColor"
  158. :text-position="getDateTimeTextPosition"
  159. :border-color="inputBorderColor"
  160. :start="item.min ? item.min : ''"
  161. :end="item.max ? item.max : ''">
  162. <!-- #ifdef MP-TOUTIAO -->
  163. {{item.value||''}}
  164. <!-- #endif -->
  165. </app-datetime-picker>
  166. </view>
  167. </view>
  168. <view :key="index" v-if="item.key=='radio'"
  169. class="item"
  170. :class="[itemClass, index===0 ? `is-first-item` : ``,]"
  171. :style="{
  172. 'padding': `0 ${itemPaddingX}rpx`,
  173. 'margin-bottom': `${itemMarginY}rpx`,
  174. }">
  175. <view class="box-grow-0 cross-top label">
  176. <image v-if="showRequiredIcon && (item.is_required == 1 || item.is_required == '1')"
  177. class="required-icon"
  178. src="/static/image/icon/required.png"></image>
  179. <view class="name-key"
  180. :class="[`text-align-${labelTextAlign}`]"
  181. :style="{
  182. 'color': labelColor
  183. }">{{item.name}}
  184. </view>
  185. </view>
  186. <view class="box-grow-1" :style="{
  187. padding: labelPosition === 'top' ? `0 0` : `0 12rpx`,
  188. }">
  189. <app-radio-group :list="item.list" v-model="item.value"
  190. :color="selectBoxColor"
  191. type="round"
  192. :height="74"
  193. @change="checkChange"></app-radio-group>
  194. </view>
  195. </view>
  196. <view :key="index" v-if="item.key=='checkbox'"
  197. class="item"
  198. :class="[itemClass, index===0 ? `is-first-item` : ``,]"
  199. :style="{
  200. 'padding': `0 ${itemPaddingX}rpx`,
  201. 'margin-bottom': `${itemMarginY}rpx`,
  202. }">
  203. <view class="box-grow-0 cross-top label">
  204. <image v-if="showRequiredIcon && (item.is_required == 1 || item.is_required == '1')"
  205. class="required-icon"
  206. src="/static/image/icon/required.png"></image>
  207. <view class="name-key"
  208. :class="[`text-align-${labelTextAlign}`]"
  209. :style="{
  210. 'color': labelColor
  211. }">{{item.name}}
  212. </view>
  213. </view>
  214. <view class="box-grow-1 dir-left-wrap" :style="{
  215. padding: labelPosition === 'top' ? `0 0` : `0 12rpx`,
  216. }">
  217. <app-diy-form-checkbox-group :list="item.list"
  218. v-model="item.value"
  219. :color="selectBoxColor"
  220. @change="checkChange"></app-diy-form-checkbox-group>
  221. </view>
  222. </view>
  223. <view :key="index" v-if="item.key=='img_upload'"
  224. class="item"
  225. :class="[itemClass, index===0 ? `is-first-item` : ``,]"
  226. :style="{
  227. 'padding': `0 ${itemPaddingX}rpx`,
  228. 'margin-bottom': `${itemMarginY}rpx`,
  229. }">
  230. <view class="box-grow-0 cross-top label">
  231. <image v-if="showRequiredIcon && (item.is_required == 1 || item.is_required == '1')"
  232. class="required-icon"
  233. src="/static/image/icon/required.png"></image>
  234. <view class="name-key"
  235. :class="[`text-align-${labelTextAlign}`]"
  236. :style="{
  237. 'color': labelColor
  238. }">{{item.name}}
  239. </view>
  240. </view>
  241. <view class="box-grow-1 dir-left-wrap" :style="{
  242. padding: labelPosition === 'top' ? `12rpx 0` : `12rpx 12rpx`,
  243. }">
  244. <!-- 普通图片 -->
  245. <template v-if="item.img_type == 1">
  246. <app-upload-image
  247. :value="uploadShowImage(item)"
  248. :max-num="item.num ? item.num:1"
  249. @image-event="handleImageUpload"
  250. :sign="`${index}`"
  251. :show-number="false"
  252. ></app-upload-image>
  253. </template>
  254. <!-- 身份证,正反面 -->
  255. <template v-if="item.img_type == 2">
  256. <app-upload-image
  257. :value="(item.value && item.value[0])?[item.value[0]]:null"
  258. style="margin-right: 12rpx"
  259. :max-num="1"
  260. @image-event="handleUserIdFrontUpload"
  261. :sign="`${index}`"
  262. text="身份证正面"
  263. :show-number="false"
  264. default-img="/static/image/user-id-card-front.png"></app-upload-image>
  265. <app-upload-image
  266. :value="(item.value && item.value[1])?[item.value[1]]:null"
  267. :max-num="1"
  268. @image-event="handleUserIdBackUpload"
  269. :sign="`${index}`"
  270. text="身份证反面"
  271. :show-number="false"
  272. default-img="/static/image/user-id-card-back.png"></app-upload-image>
  273. </template>
  274. <!-- 营业执照 -->
  275. <template v-if="item.img_type == 3">
  276. <app-upload-image
  277. :value="item.value?[item.value]:null"
  278. :max-num="1"
  279. @image-event="handleImageUpload"
  280. :sign="`${index}`"
  281. text="营业执照"
  282. :show-number="false"
  283. default-img="/static/image/company-license.png"></app-upload-image>
  284. </template>
  285. </view>
  286. </view>
  287. </template>
  288. </view>
  289. <view class="main-center cross-center scroll-bar" v-if="showScrollBtn"
  290. @click="showAllItems = !showAllItems">
  291. <view class="cross-center">点击{{showAllItems?'收起':'展开'}}</view>
  292. <view class="cross-center">
  293. <image v-if="showAllItems" src="/static/image/icon/icon-up.png"
  294. style="width: 18rpx;height: 10rpx;"></image>
  295. <image v-else src="/static/image/icon/icon-down.png"
  296. style="width: 18rpx;height: 10rpx;"></image>
  297. </view>
  298. </view>
  299. <view v-if="showSubmit" class="submit" :style="{
  300. 'padding': `${submitBtnMargin}rpx ${submitBtnPadding}rpx 24rpx`,
  301. }">
  302. <app-form-id @click="submit">
  303. <view class="submit-button" :style="{
  304. 'background-color': submitBtnBackground,
  305. 'border-color': submitBtnBorderColor,
  306. 'color': submitBtnTextColor,
  307. 'border-radius': `${submitBtnRadius}rpx`,
  308. 'height': `${submitBtnHeight}rpx`,
  309. 'line-height': `${submitBtnHeight-2}rpx`,
  310. }">{{submitBtnText}}
  311. </view>
  312. </app-form-id>
  313. </view>
  314. </view>
  315. </view>
  316. </template>
  317. <script>
  318. import AppDatetimePicker from '../../basic-component/app-datetime-picker/app-datetime-picker.vue';
  319. import AppRadio from "../../basic-component/app-radio/app-radio";
  320. import AppRadioGroup from "../../basic-component/app-radio/app-radio-group";
  321. import AppDiyFormCheckboxGroup from "./app-diy-form-checkbox-group";
  322. import AppUploadImage from "../../basic-component/app-upload-image/app-upload-image";
  323. import AppTextarea from "../../basic-component/app-textarea/app-textarea";
  324. export default {
  325. name: 'app-diy-form',
  326. components: {AppTextarea, AppUploadImage, AppDiyFormCheckboxGroup, AppRadioGroup, AppRadio, AppDatetimePicker},
  327. props: {
  328. sign: {
  329. default: null,
  330. },
  331. datePadding: {
  332. type: String,
  333. default: '0 24rpx',
  334. },
  335. title: {
  336. type: String,
  337. default: null,
  338. },
  339. backgroundColor: {
  340. default: '#ffffff',
  341. },
  342. backgroundImage: {
  343. default: null,
  344. },
  345. backgroundPosition: {
  346. default: 'center',
  347. },
  348. backgroundWidth: {
  349. default: 100,
  350. },
  351. backgroundHeight: {
  352. default: 100,
  353. },
  354. backgroundRepeat: {
  355. default: 'no-repeat',
  356. },
  357. marginTop: {
  358. default: 0,
  359. },
  360. marginBottom: {
  361. default: 0,
  362. },
  363. paddingTop: {
  364. default: 0,
  365. },
  366. paddingBottom: {
  367. default: 0,
  368. },
  369. list: {
  370. type: Array,
  371. default: [],
  372. },
  373. showRequiredIcon: {
  374. type: Boolean,
  375. default: false,
  376. },
  377. itemPaddingX: {
  378. default: 24,
  379. },
  380. itemMarginY: {
  381. default: 0,
  382. },
  383. itemHeight: {
  384. type: Number,
  385. default: 88,
  386. },
  387. showItemBorder: {
  388. default: true,
  389. },
  390. labelPosition: {
  391. default: 'left',
  392. },
  393. labelColor: {
  394. default: '#666666',
  395. },
  396. labelTextAlign: {
  397. default: 'right',
  398. },
  399. showInputBorder: {
  400. type: Boolean,
  401. default: false,
  402. },
  403. inputBackground: {
  404. default: '#ffffff',
  405. },
  406. inputBorderColor: {
  407. default: '#c0c4cc',
  408. },
  409. inputTextColor: {
  410. default: '#666666',
  411. },
  412. inputPlaceholderColor: {
  413. default: '#bbbbbb',
  414. },
  415. inputRadius: {
  416. default: 0,
  417. },
  418. showSubmit: {
  419. type: Boolean,
  420. default: false,
  421. },
  422. submitUrl: {
  423. type: String,
  424. default: null,
  425. },
  426. submitBtnText: {
  427. default: '提交',
  428. },
  429. submitBtnHeight: {
  430. default: 80,
  431. },
  432. submitBtnPadding: {
  433. default: 24,
  434. },
  435. submitBtnMargin: {
  436. default: 40,
  437. },
  438. submitBtnRadius: {
  439. default: 40,
  440. },
  441. submitBtnBackground: {
  442. default: '#ff4544',
  443. },
  444. submitBtnBorderColor: {
  445. default: '#ff4544',
  446. },
  447. submitBtnTextColor: {
  448. default: '#ffffff',
  449. },
  450. showScrollBtn: {
  451. default: false,
  452. },
  453. labelFs28: {
  454. default: false,
  455. },
  456. marginColor: {
  457. default: '#ffffff',
  458. },
  459. selectBoxColor: {
  460. default: '#ff4544',
  461. },
  462. },
  463. data() {
  464. const newList = [];
  465. for (let i in this.list) {
  466. const item = this.list[i];
  467. if (typeof item.default === 'undefined') {
  468. item.default = null;
  469. }
  470. if (typeof item.value === 'undefined' || item.value === null || item.value === '') {
  471. item.value = item.default;
  472. }
  473. item.hint = item.hint || '';
  474. if (item.key === 'radio' || item.key === 'checkbox') {
  475. if (!item.list) item.list = [];
  476. for (let j in item.list) {
  477. if (!item.list[j].value || item.list[j].value === false || item.list[j].value === 'false') {
  478. item.list[j].value = false;
  479. } else {
  480. item.list[j].value = true;
  481. }
  482. }
  483. }
  484. if (item.key === 'img_upload' && (item.img_type === 2 || item.img_type === '2') && !item.value) {
  485. item.value = ['', ''];
  486. }
  487. if(item.key == 'text') {
  488. }
  489. newList[i] = item;
  490. }
  491. return {
  492. myList: newList,
  493. randomString: '',
  494. validateResult: {
  495. hasError: false,
  496. errors: [],
  497. },
  498. showAllItems: this.showScrollBtn ? false : true,
  499. };
  500. },
  501. computed: {
  502. uploadShowImage() {
  503. return function (item) {
  504. if (Array.isArray(item.value)) {
  505. return item.value;
  506. }
  507. if (item.value) {
  508. return [item.value];
  509. }
  510. return null;
  511. }
  512. },
  513. itemClass() {
  514. if (this.labelPosition === 'left') {
  515. return 'label-left dir-left-nowrap cross-top';
  516. }
  517. if (this.labelPosition === 'inset') {
  518. return 'label-inset dir-left-nowrap cross-top';
  519. }
  520. if (this.labelPosition === 'top') {
  521. return 'label-top';
  522. }
  523. },
  524. getDateTimeTextPosition() {
  525. if (this.labelPosition === 'top') {
  526. return 'left';
  527. }
  528. return 'right';
  529. },
  530. getInputPaddingLeft() {
  531. if (this.labelPosition === 'top') {
  532. if (this.showInputBorder) {
  533. return 24;
  534. } else {
  535. return 0;
  536. }
  537. }
  538. return 24;
  539. },
  540. },
  541. created() {
  542. this.validate();
  543. this.outputData();
  544. },
  545. methods: {
  546. textInput() {
  547. this.outputData();
  548. },
  549. datetimeChange() {
  550. this.outputData();
  551. },
  552. checkChange() {
  553. setTimeout(() => {
  554. this.outputData();
  555. }, 10);
  556. },
  557. handleImageUpload(e) {
  558. const index = parseInt(e.sign);
  559. if (e.imageList.length === 1) {
  560. this.myList[index].value = e.imageList[0];
  561. } else if (e.imageList.length > 0) {
  562. this.myList[index].value = e.imageList;
  563. } else {
  564. this.myList[index].value = '';
  565. }
  566. this.outputData();
  567. },
  568. handleUserIdFrontUpload(e) {
  569. const index = parseInt(e.sign);
  570. if (e.imageList.length > 0) {
  571. this.myList[index].value[0] = e.imageList[0];
  572. } else {
  573. this.myList[index].value[0] = '';
  574. }
  575. this.outputData();
  576. },
  577. handleUserIdBackUpload(e) {
  578. const index = parseInt(e.sign);
  579. if (e.imageList.length > 0) {
  580. this.myList[index].value[1] = e.imageList[0];
  581. } else {
  582. this.myList[index].value[1] = '';
  583. }
  584. this.outputData();
  585. },
  586. validate() {
  587. this.validateResult = {
  588. hasError: false,
  589. errors: [],
  590. };
  591. for (let i in this.myList) {
  592. const item = this.myList[i];
  593. if (item.is_required === 1 || item.is_required === '1') {
  594. if (typeof item.value === 'undefined' || item.value === null || item.value === '') {
  595. this.validateResult.hasError = true;
  596. this.validateResult.errors.push({
  597. index: i,
  598. msg: `"${item.name}"不能为空。`,
  599. });
  600. continue;
  601. }
  602. if (item.img_type && parseInt(item.img_type) === 2) {
  603. if (!item.value || !item.value.length) {
  604. this.validateResult.hasError = true;
  605. this.validateResult.errors.push({
  606. index: i,
  607. msg: `"${item.name}"不能为空。`,
  608. });
  609. continue;
  610. }
  611. let imgErr = false;
  612. for (let j in item.value) {
  613. if (item.value[j] === null || item.value[j] === '') {
  614. imgErr = true;
  615. break;
  616. }
  617. }
  618. if (imgErr) {
  619. this.validateResult.hasError = true;
  620. this.validateResult.errors.push({
  621. index: i,
  622. msg: `"${item.name}"不能为空。`,
  623. });
  624. continue;
  625. }
  626. }
  627. }
  628. }
  629. this.$emit('validate', this.validateResult, this.sign);
  630. },
  631. outputData() {
  632. this.validate();
  633. for (let i in this.myList) {
  634. this.myList[i].label = this.myList[i].name;
  635. this.myList[i].required = this.myList[i].is_required;
  636. }
  637. this.$emit('input', this.myList, this.sign);
  638. // #ifdef MP-TOUTIAO
  639. setTimeout(() => {
  640. this.randomString = this.$utils.randomString(32);
  641. }, 1);
  642. // #endif
  643. },
  644. submit() {
  645. this.outputData();
  646. if (this.validateResult.hasError && this.validateResult.errors) {
  647. uni.showModal({
  648. title: '提示',
  649. content: this.validateResult.errors[0].msg,
  650. showCancel: false,
  651. });
  652. return;
  653. }
  654. uni.showLoading({
  655. mask: true,
  656. title: '正在提交...',
  657. });
  658. this.$request({
  659. url: this.submitUrl ? this.submitUrl : this.$api.diy.page_store,
  660. method: 'post',
  661. data: {
  662. form_data: JSON.stringify(this.myList),
  663. },
  664. }).then(response => {
  665. uni.hideLoading();
  666. if (response.code === 0) {
  667. setTimeout(() => {
  668. let copyList = this.myList;
  669. for (let i in copyList) {
  670. copyList[i].value = copyList[i].default;
  671. }
  672. this.myList = [];
  673. setTimeout(() => {
  674. this.myList = copyList;
  675. }, 0);
  676. }, 300);
  677. uni.showModal({
  678. title: '提示',
  679. content: response.msg || '提交成功',
  680. showCancel: false,
  681. });
  682. } else {
  683. uni.showModal({
  684. title: '提示',
  685. content: response.msg || '提交失败',
  686. showCancel: false,
  687. });
  688. }
  689. }).catch(() => {
  690. uni.hideLoading();
  691. });
  692. },
  693. },
  694. }
  695. </script>
  696. <style scoped lang="scss">
  697. .name-key {
  698. width: 100%;
  699. text-align: right;
  700. font-size: #{32rpx};
  701. color: #353535
  702. }
  703. .name-key.text-align-left {
  704. text-align: left;
  705. }
  706. .name-key.text-align-right {
  707. text-align: right;
  708. }
  709. .title {
  710. padding: #{24rpx};
  711. color: #999;
  712. font-size: #{26rpx};
  713. }
  714. .arrow {
  715. width: #{12rpx};
  716. height: #{22rpx};
  717. }
  718. .scroll-bar {
  719. border-top: #{1rpx} solid $uni-weak-color-one;
  720. height: #{72rpx};
  721. color: $uni-general-color-two;
  722. image {
  723. margin-left: #{16rpx};
  724. }
  725. }
  726. .list {
  727. .item {
  728. height: 0 !important;
  729. overflow: hidden;
  730. .label {
  731. min-width: #{125rpx};
  732. padding: #{12rpx} #{12rpx} #{12rpx} 0;
  733. height: 100%;
  734. position: relative;
  735. }
  736. .required-icon {
  737. width: #{15rpx};
  738. height: #{15rpx};
  739. display: inline-block;
  740. position: absolute;
  741. left: #{-14rpx};
  742. top: #{23rpx};
  743. }
  744. }
  745. .item.is-first-item {
  746. height: auto !important;
  747. overflow: auto;
  748. }
  749. .item.label-left {
  750. .name-key {
  751. max-width: #{200rpx};
  752. }
  753. }
  754. .item.label-top {
  755. .name-key {
  756. text-align: left;
  757. }
  758. .label {
  759. padding: #{20rpx} #{12rpx} #{8rpx} 0;
  760. }
  761. }
  762. .item:last-child {
  763. margin-bottom: 0 !important;
  764. }
  765. }
  766. .show-all {
  767. .item {
  768. height: auto !important;
  769. overflow: auto;
  770. }
  771. }
  772. .show-first {
  773. .item {
  774. margin-bottom: 0 !important;
  775. border: none !important;
  776. }
  777. }
  778. .item-border {
  779. .item {
  780. border-bottom: #{2rpx} solid $uni-weak-color-one;
  781. }
  782. .item:last-child {
  783. border-bottom: none;
  784. }
  785. }
  786. .submit-button {
  787. text-align: center;
  788. border: #{1rpx} solid;
  789. }
  790. .submit-button:active {
  791. box-shadow: inset 0 0 #{1000rpx} rgba(0, 0, 0, .15);
  792. }
  793. .label-fs-28 {
  794. .name-key {
  795. font-size: #{28rpx};
  796. }
  797. }
  798. </style>