my_form.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978
  1. <template>
  2. <view>
  3. <view class="requiredFieldOnly-head" v-if="requiredFieldOnly">
  4. <view class="label">
  5. 基本信息
  6. </view>
  7. <view class="content">
  8. 仅显示必填信息<text style="padding: 0 2.5px;" /> <u-switch activeColor="#C40C24" v-model="unShowAll" />
  9. </view>
  10. </view>
  11. <slot name="head" />
  12. <block v-for="(item, index) in list " :key="item.key">
  13. <block v-if="item.isMust || !unShowAll">
  14. <!-- 文本输入 -->
  15. <view class="input-box" v-if="item.type == 'text'"
  16. :style="{ marginTop: tovw(item.marginTop || 0), opacity: item.disabled ? 0.7 : 1 }"
  17. @click="focusLabel = item.label">
  18. <view class="box" :class="item.unBorBot ? '' : 'borBot'">
  19. <view class="label">
  20. <text class="must" v-if="item.isMust">*</text>
  21. {{ item.label }}:
  22. </view>
  23. <view class="content-box">
  24. <view class="content">
  25. <input v-if="item.inputmode == 'number'" type="number" :disabled="item.disabled"
  26. placeholder-style="color: #BBBBBB;font-family: Source Han Sans SC, Source Han Sans SC;"
  27. :focus="focusLabel == item.label" :placeholder="item.placeholder || '请填写' + item.label"
  28. :value="item.value" :style="{ width: item.value ? '220px' : '240px' }"
  29. @input="onInput($event, index)" :maxlength="item.maxlength || '499'"
  30. confirm-type="done" />
  31. <input v-else-if="item.inputmode == 'digit'" type="digit" :disabled="item.disabled"
  32. placeholder-style="color: #BBBBBB;font-family: Source Han Sans SC, Source Han Sans SC;"
  33. :focus="focusLabel == item.label" :placeholder="item.placeholder || '请填写' + item.label"
  34. :value="item.value" :style="{ width: item.value ? '220px' : '240px' }"
  35. @input="onInput($event, index)" :maxlength="item.maxlength || '499'"
  36. confirm-type="done" />
  37. <textarea v-else :disabled="item.disabled"
  38. placeholder-style="color: #BBBBBB;font-family: Source Han Sans SC, Source Han Sans SC;"
  39. auto-height type="text" :focus="focusLabel == item.label"
  40. :placeholder="item.placeholder || '请填写' + item.label" :value="item.value"
  41. :style="{ width: item.value ? '220px' : '240px' }" @input="onInput($event, index)"
  42. :maxlength="item.maxlength || '499'" confirm-type="done" />
  43. <icon v-if="item.value && !item.disabled" class="icon" type="clear" size="3.733vw"
  44. @click="onClearInput(index)" />
  45. </view>
  46. <view v-if="item.errText" class="err-text">
  47. <icon class="icon" color="#E3041F" type="clear" size="2.733vw" />
  48. {{ item.errText }}
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 文本域 -->
  54. <view class="textarea-box" v-else-if="item.type == 'textarea'">
  55. <textarea class="textarea" :class="item.unBorBot ? '' : 'borBot'" :disabled="item.disabled"
  56. placeholder-style="color: #BBBBBB;font-family: Source Han Sans SC, Source Han Sans SC;" type="text"
  57. :placeholder="item.placeholder || '请填写' + item.label" :value="item.value"
  58. @input="onInput($event, index)" :maxlength="item.maxlength || '499'" confirm-type="done" />
  59. </view>
  60. <!-- 文本域2 -->
  61. <view class="textarea-box2" v-else-if="item.type == 'textarea2'" :style="{ marginTop: tovw(item.marginTop || 0)}">
  62. <view class="label">
  63. <text class="must" v-if="item.isMust">*</text>
  64. {{ item.label }}:
  65. </view>
  66. <textarea class="textarea" :class="item.unBorBot ? '' : 'borBot'" :disabled="item.disabled"
  67. placeholder-style="color: #BBBBBB;font-family: Source Han Sans SC, Source Han Sans SC;" type="text"
  68. :placeholder="item.placeholder || '请填写' + item.label" :value="item.value"
  69. @input="onInput($event, index)" :maxlength="item.maxlength || '499'" confirm-type="done" />
  70. </view>
  71. <!-- 自定义选项分类 -->
  72. <view class="custom-class-box" v-else-if="item.type == 'customClass'"
  73. :style="{ marginTop: tovw(item.marginTop || 0) }">
  74. <view class="head">
  75. <view class="label">
  76. <text class="must" style="color: #E3041F;" v-if="item.isMust">*</text>
  77. {{ item.label }}
  78. </view>
  79. <view class="state">
  80. {{ item.isMultipleChoice ? '可多选' : '仅单选' }}
  81. </view>
  82. </view>
  83. <view class="options">
  84. <view class="option"
  85. :class="item.isMultipleChoice ? (item.value.includes(option.value) ? 'active' : '') : (item.value == option.value ? 'active' : '')"
  86. v-for=" option in item.list " :key="option.value" hover-class="navigator-hover"
  87. @click="changOptions(option.value, index)">
  88. {{ option.remarks }}
  89. </view>
  90. </view>
  91. </view>
  92. <!-- 选择所在地区 -->
  93. <picker class="region" @change="selectRegion($event, index)" mode='region' :disabled="item.disabled"
  94. :value="item.value" v-else-if="item.type == 'region'"
  95. :style="{ marginTop: tovw(item.marginTop || 0), opacity: item.disabled ? 0.7 : 1 }">
  96. <view class="box" :class="item.unBorBot ? '' : 'borBot'">
  97. <view class="label">
  98. <text class="must" v-if="item.isMust">*</text>
  99. {{ item.label }}:
  100. </view>
  101. <view class="content-box">
  102. <view class="value" v-if="item.value.length">
  103. {{ item.value.join(",") }}
  104. </view>
  105. <view v-else class="placeholder" hover-class="none">
  106. {{ item.placeholder || '请选择' + item.label }}
  107. </view>
  108. <view v-if="!item.disabled" class="iconfont icon-a-wodetiaozhuan" />
  109. </view>
  110. </view>
  111. </picker>
  112. <!-- 日期 -->
  113. <picker class="region" @change="selectRegion($event, index)" mode='date' :disabled="item.disabled"
  114. :value="item.value" v-else-if="item.type == 'date'"
  115. :style="{ marginTop: tovw(item.marginTop || 0), opacity: item.disabled ? 0.7 : 1 }">
  116. <view class="box" :class="item.unBorBot ? '' : 'borBot'">
  117. <view class="label">
  118. <text class="must" v-if="item.isMust">*</text>
  119. {{ item.label }}:
  120. </view>
  121. <view class="content-box">
  122. <view class="value" v-if="item.value">
  123. {{ item.value }}
  124. </view>
  125. <view v-else class="placeholder" hover-class="none">
  126. {{ item.placeholder || '请选择' + item.label }}
  127. </view>
  128. <view v-if="!item.disabled" class="iconfont icon-a-wodetiaozhuan" />
  129. </view>
  130. </view>
  131. </picker>
  132. <!-- 上传附件 -->
  133. <view class="custom-class-box" v-else-if="item.type == 'upload'"
  134. :style="{ marginTop: tovw(item.marginTop || 0) }">
  135. <view class="head">
  136. <view class="label">
  137. <text class="must" v-if="item.isMust">*</text>
  138. {{ item.label }}
  139. </view>
  140. <view class="state">
  141. {{ item.placeholder }}
  142. </view>
  143. </view>
  144. <view class="content">
  145. <view class="file-box" v-for="file in item.value" :key="file.attachmentid">
  146. <image class="image" v-if="file.fileType == 'image'" :src="file.url" mode="aspectFill"
  147. lazy-load="true" @click="previewImg(file)" />
  148. <video v-else-if="file.fileType == 'video'" class="video" :poster="file.subfiles[0].url"
  149. :src="file.url" />
  150. <image class="delete" @click.stop="deleteFile(file, index)"
  151. src="https://yossys06593.obs.cn-east-3.myhuaweicloud.com:443/202404241713944430197B47af9b2f.png"
  152. mode="widthFix" />
  153. </view>
  154. <My_upload v-if="item.allowUpload" :showLoading="false" :maxCount="item.maxCount || 99"
  155. :accept="item.accept" @uploadCallback="uploadCallback($event, index)"
  156. @onLoading="onUploadLoading($event, index)">
  157. <view class="upload-box"
  158. v-if="item.maxCount ? item.value.length != item.maxCount : item.value.length != 99"
  159. hover-class="navigator-hover">
  160. <u-loading-icon v-if="item.loading" />
  161. <text v-else class="iconfont icon-xiazai" />
  162. <text style="margin-left: 5px;">上传</text>
  163. </view>
  164. </My_upload>
  165. </view>
  166. </view>
  167. <!-- 开关 -->
  168. <view class="region" v-else-if="item.type == 'switch'">
  169. <view class="box" :class="item.unBorBot ? '' : 'borBot'">
  170. <view class="label">
  171. <text class="must" v-if="item.isMust">*</text>
  172. {{ item.label }}:
  173. </view>
  174. <view class="content-box">
  175. <view />
  176. <u-switch activeColor="#70D95D" v-model="item.value" :disabled="item.disabled"
  177. @change="switchChange($event, index)" />
  178. </view>
  179. </view>
  180. </view>
  181. <!-- 性别 -->
  182. <view class="region" v-else-if="item.type == 'sex'">
  183. <view class="box" :class="item.unBorBot ? '' : 'borBot'">
  184. <view class="label">
  185. <text class="must" v-if="item.isMust">*</text>
  186. {{ item.label }}:
  187. </view>
  188. <u-radio-group v-model="item.value" placement="row" @change="groupChange($event, index)">
  189. <u-radio :customStyle="{ marginRight: tovw(60) }" label="男" name="男" />
  190. <u-radio label="女" name="女" />
  191. </u-radio-group>
  192. </view>
  193. </view>
  194. <!-- 单选 -->
  195. <view class="region" v-else-if="item.type == 'radio'">
  196. <view class="box" :class="item.unBorBot ? '' : 'borBot'">
  197. <view class="label">
  198. <text class="must" v-if="item.isMust">*</text>
  199. {{ item.label }}:
  200. </view>
  201. <u-radio-group v-model="item.value" :placement="item.placement || 'row'"
  202. @change="groupChange($event, index)">
  203. <u-radio v-for="option in item.options"
  204. :customStyle="{ marginRight: tovw(option.marginRight || item.marginRight || 0), marginTop: tovw(option.marginTop || item.marginTop || 0) }"
  205. :key="option.label" :label="option.label" :name="option.name" />
  206. </u-radio-group>
  207. </view>
  208. </view>
  209. <!-- 路由选择器 -->
  210. <view class="region" v-else-if="item.type == 'route'"
  211. :style="{ marginTop: tovw(item.marginTop || 0), opacity: item.disabled ? 0.7 : 1 }"
  212. @click="item.disabled ? '' : toRoute(item, index)">
  213. <view class="box" :class="item.unBorBot ? '' : 'borBot'">
  214. <view class="label">
  215. <text class="must" v-if="item.isMust">*</text>
  216. {{ item.label }}:
  217. </view>
  218. <view class="content-box">
  219. <view class="value" v-if="item.showValue.length">
  220. {{ item.showValue.join(",") }}
  221. </view>
  222. <view v-else class="placeholder" hover-class="none">
  223. {{ item.placeholder || '请选择' + item.label }}
  224. </view>
  225. <view v-if="!item.disabled" class="iconfont icon-a-wodetiaozhuan" />
  226. </view>
  227. </view>
  228. </view>
  229. <!-- 标签 -->
  230. <view class="tag-box custom-class-box " v-else-if="item.type == 'tag'"
  231. :style="{ marginTop: tovw(item.marginTop || 0) }">
  232. <text class="label">{{ item.label }}</text>
  233. <view class="tag-list">
  234. <view class="tag" v-for="tag in item.value" :key="tag">
  235. <text>{{ tag }}</text>
  236. <view @click="delTag(tag, index)" class="del">x</view>
  237. </view>
  238. <view>
  239. <u-modal :title="item.label" :show="showTagModal" style="flex: 0 !important;"
  240. confirmColor='#C30D23' ref="uModal" showCancelButton :asyncClose="false"
  241. @confirm="addTagSend(index)" @cancel="showTagModal = false">
  242. <view class="slot-content">
  243. <view v-if="item.errText" class="err-text" style="margin-bottom: 10px;">
  244. <icon class="icon" color="#E3041F" type="clear" size="2.733vw" />
  245. {{ item.errText }}
  246. </view>
  247. <u--input :maxlength="item.maxlength?item.maxlength:'99999'" :focus="showUModal" @input="onTagInput($event, index)"
  248. :placeholder="item.placeholder || '请输入'" v-model="tagValue" border="bottom"
  249. clearable />
  250. </view>
  251. </u-modal>
  252. <view class="add-tag" @click="showTagModal = true">+ 添加</view>
  253. </view>
  254. </view>
  255. </view>
  256. </block>
  257. </block>
  258. </view>
  259. </template>
  260. <script>
  261. import { formattedFiles, viewImage } from "../utils/settleFiles.js"
  262. export default {
  263. name: "my_form",
  264. props: {
  265. form: {
  266. type: Array,
  267. default: []
  268. },
  269. isUncomplete: {
  270. type: Function
  271. },
  272. onUploading: {
  273. type: Function
  274. },
  275. requiredFieldOnly: {
  276. type: Boolean
  277. },
  278. isShowAll: {
  279. type: Function
  280. },
  281. interrupt: {
  282. type: Function
  283. }
  284. },
  285. data() {
  286. return {
  287. list: [],
  288. focusLabel: "",
  289. unShowAll: false,
  290. showTagModal: false,
  291. tagValue: ''
  292. }
  293. },
  294. watch: {
  295. form: {
  296. handler: function (newVal) {
  297. if (newVal) {
  298. this.list = JSON.parse(JSON.stringify(newVal));
  299. setTimeout(() => {
  300. this.verify()
  301. }, 200);
  302. }
  303. },
  304. immediate: true,
  305. },
  306. unShowAll: function (newVal) {
  307. this.$emit("isShowAll", newVal)
  308. }
  309. },
  310. async created() {
  311. /* let list = [{
  312. key: "name",
  313. type: "text",
  314. label: "标题",
  315. isMust: true,//是否必填
  316. value: "",
  317. inputmode:"", //https://uniapp.dcloud.net.cn/component/input.html#type
  318. marginTop: 10,
  319. verify:[],
  320. }, {
  321. key: "Class",
  322. type: "customClass",
  323. label: "标题",
  324. isMust: false,//是否必填
  325. isMultipleChoice: true,//是否多选
  326. value: [],// 多选[] 单选 ""
  327. isMust: true,//是否必填
  328. list: await this.getCustomClass('picturespace'),
  329. marginTop: 10
  330. },{
  331. key: "attachmentids",
  332. type: "upload",
  333. label: "图片/视频",
  334. accept:"all",
  335. placeholder: "可上传多个视频或图片",
  336. ownertable: "temporary",
  337. ownerid: 999,
  338. usetype: 'default',
  339. allowUpload: true,
  340. allowDelete: true,
  341. value:[],
  342. marginTop: 10
  343. }, {
  344. key: "region",
  345. type: "region",
  346. label: "所在地区",
  347. isMust: true,//是否必填
  348. value: [],
  349. }, {
  350. key: "address",
  351. type: "textarea",
  352. label: "详细地址",
  353. isMust: true,//是否必填
  354. value: '',
  355. }, {
  356. key: "isdefault",
  357. type: "switch",
  358. label: "设为默认地址",
  359. isMust: false,//是否必填
  360. value: false,
  361. isNum: true,
  362. unBorBot: true
  363. }] */
  364. },
  365. methods: {
  366. delTag(tag, index) {
  367. let item = this.list[index];
  368. console.log(tag);
  369. item.value.splice(item.value.indexOf(tag), 1)
  370. this.$set(this.list[index], 'value', item.value)
  371. },
  372. addTagSend(index) {
  373. let item = this.list[index]
  374. if (!item.errText) {
  375. item.value.push(this.tagValue)
  376. this.$set(this.list[index], 'value', item.value)
  377. this.tagValue = ''
  378. this.showTagModal = false
  379. }
  380. },
  381. toRoute(item, index) {
  382. let url = item.path;
  383. if (item.showValue.length) {
  384. let obj = JSON.stringify({
  385. value: item.value,
  386. showValue: item.showValue
  387. })
  388. url += (url.indexOf("?") == -1 ? '?alreadySelecteds=' : '&alreadySelecteds=') + obj
  389. }
  390. uni.navigateTo({
  391. url
  392. });
  393. this.$Http.routeSelected = function (selected) {
  394. this.$emit('interrupt', item, selected, index)
  395. delete this.$Http.routeSelected;
  396. }.bind(this)
  397. },
  398. onTagInput(e, index) {
  399. let item = this.list[index];
  400. item.errText = "";
  401. if (item.verify && item.verify.length && this.tagValue != '') {
  402. let err = item.verify.find(r => !new RegExp(r.reg).test(this.tagValue));
  403. if (err) this.$set(this.list[index], 'errText', err.errText)
  404. }
  405. this.verify()
  406. },
  407. onInput(e, index) {
  408. let item = this.list[index];
  409. item.errText = "";
  410. this.$set(this.list[index], 'value', e.detail.value)
  411. if (item.verify && item.verify.length && item.value != '') {
  412. let err = item.verify.find(r => !new RegExp(r.reg).test(item.value));
  413. if (err) this.$set(this.list[index], 'errText', err.errText)
  414. }
  415. this.verify()
  416. },
  417. setItem(index, item, back = false) {
  418. this.$set(this.list, index, item)
  419. this.verify()
  420. if (back) uni.navigateBack();
  421. },
  422. setValue(index, value, back = false) {
  423. this.$set(this.list[index], 'value', value)
  424. this.verify()
  425. if (back) uni.navigateBack();
  426. },
  427. onClearInput(index) {
  428. let item = this.list[index];
  429. item.errText = ''
  430. this.$set(this.list[index], 'value', '')
  431. this.verify()
  432. },
  433. switchChange(e, index) {
  434. this.$set(this.list[index], 'value', e)
  435. this.verify()
  436. },
  437. changOptions(value, index) {
  438. let item = this.list[index];
  439. if (item.isMultipleChoice) {
  440. let i = -1;
  441. try {
  442. i = item.value.findIndex(v => v == value)
  443. } catch (error) {
  444. }
  445. if (i == -1) {
  446. item.value.push(value)
  447. } else {
  448. item.value.splice(i, 1)
  449. }
  450. this.$set(this.list[index], 'value', item.value)
  451. } else {
  452. this.$set(this.list[index], 'value', value)
  453. }
  454. this.verify()
  455. },
  456. verify() {
  457. let list = this.list.filter(v => v.isMust);
  458. let Uncomplete = false;
  459. if (list.length) Uncomplete = list.some(v => {
  460. let res = false;
  461. if (v.type == 'customClass') {
  462. if (v.isMultipleChoice) {
  463. res = v.value.length == 0;
  464. } else {
  465. res = v.value == "";
  466. }
  467. } else if (v.type == 'upload') {
  468. res = v.value.length == 0;
  469. } else if (v.type == 'text') {
  470. res = v.value == "";
  471. if (v.errText) res = true;
  472. } else if (v.type == 'route') {
  473. res = v.showValue.length == 0;
  474. } else {
  475. res = v.value == "";
  476. }
  477. return res
  478. })
  479. if (!Uncomplete) Uncomplete = this.list.filter(v => !v.isMust).some(v => v.errText);
  480. this.$emit("isUncomplete", Uncomplete)
  481. },
  482. previewImg(item) {
  483. viewImage(item.url)
  484. },
  485. uploadCallback(attachmentids, index) {
  486. let item = this.list[index];
  487. this.$Http.basic({
  488. "classname": "system.attachment.Attachment",
  489. "method": "createFileLink",
  490. "content": {
  491. ownertable: item.ownertable,
  492. ownerid: item.ownerid,
  493. usetype: item.usetype,
  494. attachmentids
  495. }
  496. }).then(res => {
  497. console.log('绑定附件', res)
  498. if (this.cutoff(res.msg)) return;
  499. res.data = formattedFiles(res.data)
  500. item.value.push(res.data[0]);
  501. //临时文件
  502. if (res.data[0].ownertable == "temporary") try {
  503. item.temporarys.push(attachmentids[0])
  504. } catch (error) {
  505. item.temporarys = [attachmentids[0]]
  506. }
  507. this.$set(this.list[index], 'value', item.value)
  508. this.verify()
  509. })
  510. },
  511. deleteFiles() {
  512. this.list.forEach(v => {
  513. if (v.type == 'upload') {
  514. let linksids = v.value.filter(v => v.ownertable == "temporary").map(v => v.linksid)
  515. if (linksids.length) this.$Http.basic({
  516. "classname": "system.attachment.Attachment",
  517. "method": "deleteFileLink",
  518. "content": {
  519. linksids
  520. }
  521. }).then(res => {
  522. console.log("处理删除附件", res)
  523. if (this.cutoff(res.msg)) return;
  524. });
  525. }
  526. });
  527. },
  528. onUploadLoading(e, index) {
  529. this.$set(this.list[index], 'loading', e)
  530. this.$emit("onUploading", e)
  531. },
  532. groupChange(e, index) {
  533. this.$set(this.list[index], 'loading', e)
  534. this.verify()
  535. },
  536. selectRegion({ detail }, index) {
  537. this.$set(this.list[index], 'value', detail.value)
  538. this.verify()
  539. },
  540. deleteFile(flie, index) {
  541. let item = this.list[index];
  542. item.value = item.value.filter(v => v.attachmentid != flie.attachmentid)
  543. //临时文件
  544. if (flie.ownertable == "temporary") {
  545. item.temporarys = item.temporarys.filter(v => v != flie.attachmentid)
  546. this.$Http.basic({
  547. "classname": "system.attachment.Attachment",
  548. "method": "deleteFileLink",
  549. "content": {
  550. linksids: [flie.linksid]
  551. }
  552. }).then(res => {
  553. console.log("处理删除附件", res)
  554. if (this.cutoff(res.msg)) return;
  555. });
  556. } else {
  557. try {
  558. item.linksids.push(flie.linksid)
  559. } catch (error) {
  560. item.linksids = [flie.linksid]
  561. }
  562. }
  563. this.$set(this.list[index], 'value', item.value)
  564. this.verify()
  565. },
  566. submit() {
  567. return new Promise((resolve, reject) => {
  568. let res = {};
  569. this.list.forEach(v => {
  570. if (v.type == 'upload') {
  571. res.files = {
  572. temporarys: [],
  573. linksids: [],
  574. }
  575. try {
  576. res.files.temporarys = v.temporarys || []
  577. } catch (error) {
  578. }
  579. try {
  580. res.files.linksids = v.linksids || []
  581. } catch (error) {
  582. }
  583. } else if (v.type == 'region') {
  584. if (v.value.length) {
  585. res.province = v.value[0];
  586. res.city = v.value[1];
  587. res.county = v.value[2];
  588. } else {
  589. res.province = ''
  590. res.city = ''
  591. res.county = ''
  592. }
  593. } else if (v.type == 'switch') {
  594. if (v.isNum) {
  595. res[v.key] = v.value ? 1 : 0;
  596. } else {
  597. res[v.key] = v.value;
  598. }
  599. } else if (v.type == 'route') {
  600. if (v.isRadio) {
  601. const routeValue = typeof v.value.length == 'number' ? v.value.length ? v.value[0] : '' : v.value || {}
  602. if (v.keys) {
  603. v.keys.forEach(e => {
  604. res[e] = routeValue ? routeValue[e] || '' : ''
  605. })
  606. } else {
  607. res[v.key] = {
  608. name: v.showValue[0] || '',
  609. value: routeValue
  610. };
  611. }
  612. } else {
  613. res[v.key] = {
  614. name: v.showValue || [],
  615. value: v.value || []
  616. };;
  617. }
  618. } else {
  619. try {
  620. res[v.key] = v.value.trim();
  621. } catch (error) {
  622. res[v.key] = v.value;
  623. }
  624. }
  625. })
  626. resolve(res)
  627. })
  628. }
  629. },
  630. }
  631. </script>
  632. <style lang="scss">
  633. .requiredFieldOnly-head {
  634. display: flex;
  635. align-items: center;
  636. justify-content: space-between;
  637. width: 100vw;
  638. height: 45px;
  639. background: #F7F7F7;
  640. padding: 0 10px;
  641. box-sizing: border-box;
  642. .label {
  643. font-family: PingFang SC, PingFang SC;
  644. font-weight: bold;
  645. font-size: 15px;
  646. color: #333333;
  647. line-height: 22px;
  648. }
  649. .content {
  650. display: flex;
  651. align-items: center;
  652. font-family: PingFang SC, PingFang SC;
  653. font-size: 14px;
  654. color: #999999;
  655. }
  656. }
  657. .borBot {
  658. border-bottom: 1px #DDDDDD solid;
  659. }
  660. .custom-class-box {
  661. width: 100%;
  662. background: #fff;
  663. padding: 15px 0 15px 10px;
  664. box-sizing: border-box;
  665. .head {
  666. width: 355px;
  667. height: 20px;
  668. display: flex;
  669. justify-content: space-between;
  670. align-items: flex-end;
  671. .label {
  672. font-size: 14px;
  673. color: #333333;
  674. line-height: 20px;
  675. }
  676. .state {
  677. font-family: Source Han Sans SC, Source Han Sans SC;
  678. font-size: 12px;
  679. color: #999999;
  680. }
  681. }
  682. .options {
  683. display: flex;
  684. flex-wrap: wrap;
  685. .option {
  686. padding: 6px 10px;
  687. text-align: center;
  688. min-width: 81px;
  689. font-family: PingFang SC, PingFang SC;
  690. font-size: 14px;
  691. color: #333333;
  692. border-radius: 5px;
  693. background: #F2F2F2;
  694. margin-top: 10px;
  695. margin-right: 10px;
  696. box-sizing: border-box;
  697. }
  698. .active {
  699. background: #C30D23;
  700. color: #fff;
  701. }
  702. }
  703. .content {
  704. .file-box {
  705. position: relative;
  706. width: 355px;
  707. height: 240px;
  708. margin-top: 10px;
  709. .video,
  710. .image {
  711. width: 355px;
  712. height: 240px;
  713. border-radius: 5px;
  714. }
  715. .delete {
  716. position: absolute;
  717. width: 30px;
  718. top: 0;
  719. right: 0;
  720. z-index: 1;
  721. }
  722. }
  723. .upload-box {
  724. display: flex;
  725. justify-content: center;
  726. align-items: center;
  727. width: 355px;
  728. height: 45px;
  729. background: #FFFFFF;
  730. border-radius: 5px;
  731. border: 1px dashed #C30D23;
  732. font-family: Source Han Sans SC, Source Han Sans SC;
  733. font-size: 14px;
  734. color: #C30D23;
  735. margin-top: 10px;
  736. }
  737. }
  738. }
  739. .textarea-box {
  740. width: 100%;
  741. .textarea {
  742. width: 355px;
  743. height: 160px;
  744. padding: 15px 10px;
  745. box-sizing: border-box;
  746. margin: 0 auto;
  747. }
  748. }
  749. .textarea-box2 {
  750. width: 100%;
  751. display: flex;
  752. flex-direction: column;
  753. background: #ffffff;
  754. padding: 15px 0 15px 10px;
  755. .label {
  756. width: 100px;
  757. margin-right: 10px;
  758. line-height: 20px;
  759. font-family: Source Han Sans SC, Source Han Sans SC;
  760. font-size: 14px;
  761. color: #666666;
  762. flex-shrink: 0;
  763. .must {
  764. color: #E3041F;
  765. margin-right: 5px;
  766. }
  767. }
  768. .textarea {
  769. width: 355px;
  770. height: 160px;
  771. padding: 15px 10px;
  772. box-sizing: border-box;
  773. margin: 0 auto;
  774. }
  775. }
  776. .input-box {
  777. width: 100vw;
  778. background: #fff;
  779. box-sizing: border-box;
  780. padding-left: 10px;
  781. .box {
  782. display: flex;
  783. width: 100%;
  784. min-height: 54.4px;
  785. padding: 15px 0;
  786. box-sizing: border-box;
  787. align-items: center;
  788. }
  789. .label {
  790. width: 100px;
  791. margin-right: 10px;
  792. line-height: 20px;
  793. font-family: Source Han Sans SC, Source Han Sans SC;
  794. font-size: 14px;
  795. color: #666666;
  796. flex-shrink: 0;
  797. .must {
  798. color: #E3041F;
  799. margin-right: 5px;
  800. }
  801. }
  802. .content-box {
  803. padding-right: 10px;
  804. .content {
  805. flex: 1;
  806. display: flex;
  807. align-items: center;
  808. box-sizing: border-box;
  809. .icon {
  810. padding: 5px;
  811. }
  812. }
  813. .err-text {
  814. font-size: 12px;
  815. color: #E3041F;
  816. margin-bottom: -12px;
  817. .icon {
  818. margin-right: 2px;
  819. }
  820. }
  821. }
  822. }
  823. .region {
  824. width: 100vw;
  825. background: #fff;
  826. box-sizing: border-box;
  827. padding: 15px 0 0 10px;
  828. .box {
  829. display: flex;
  830. padding-bottom: 15px;
  831. padding-right: 10px;
  832. box-sizing: border-box;
  833. .label {
  834. width: 100px;
  835. margin-right: 10px;
  836. line-height: 20px;
  837. font-family: Source Han Sans SC, Source Han Sans SC;
  838. font-size: 14px;
  839. color: #666666;
  840. flex-shrink: 0;
  841. .must {
  842. color: #E3041F;
  843. margin-right: 5px;
  844. }
  845. }
  846. .content-box {
  847. flex: 1;
  848. display: flex;
  849. align-items: center;
  850. justify-content: space-between;
  851. height: 20px;
  852. line-height: 20px;
  853. .placeholder {
  854. font-family: Source Han Sans SC, Source Han Sans SC;
  855. font-size: 14px;
  856. color: #BBBBBB;
  857. }
  858. }
  859. }
  860. }
  861. .tag-box {
  862. .label {
  863. width: 100px;
  864. margin-right: 10px;
  865. line-height: 20px;
  866. font-family: Source Han Sans SC, Source Han Sans SC;
  867. font-size: 14px;
  868. color: #666666;
  869. flex-shrink: 0;
  870. .must {
  871. color: #E3041F;
  872. margin-right: 5px;
  873. }
  874. }
  875. .tag-list {
  876. display: flex;
  877. align-content: center;
  878. align-items: center;
  879. flex-wrap: wrap;
  880. font-family: PingFang SC, PingFang SC;
  881. margin-top: 10px;
  882. .err-text {
  883. font-size: 12px;
  884. color: #E3041F;
  885. margin-bottom: -12px;
  886. .icon {
  887. margin-right: 2px;
  888. }
  889. }
  890. .tag {
  891. padding: 6px 10px;
  892. background: #F2F2F2;
  893. border-radius: 5px 5px 5px 5px;
  894. margin-right: 10px;
  895. margin-bottom: 10px;
  896. font-weight: 400;
  897. font-size: 14px;
  898. color: #333333;
  899. display: flex;
  900. align-items: center;
  901. align-content: center;
  902. text-align: center;
  903. &:last-child {
  904. margin-right: 0 !important;
  905. }
  906. .del {
  907. margin-left: 10px;
  908. padding: 2px;
  909. }
  910. }
  911. .add-tag {
  912. border-radius: 5px 5px 5px 5px;
  913. border: 1px dashed #C30D23;
  914. padding: 6px 20px;
  915. color: #C30D23;
  916. font-weight: 400;
  917. margin-bottom: 10px;
  918. font-size: 14px;
  919. }
  920. }
  921. }
  922. </style>