|
@@ -54,133 +54,6 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <!-- 文本域 -->
|
|
|
- <view class="textarea-box" v-else-if="item.type == 'textarea'">
|
|
|
- <textarea class="textarea" :class="item.unBorBot ? '' : 'borBot'" :disabled="item.disabled"
|
|
|
- placeholder-style="color: #BBBBBB;font-family: Source Han Sans SC, Source Han Sans SC;" type="text"
|
|
|
- :placeholder="item.placeholder || '请填写' + item.label" :value="item.value"
|
|
|
- @input="onInput($event, index)" :maxlength="item.maxlength || '499'" confirm-type="done" />
|
|
|
- </view>
|
|
|
- <!-- 自定义选项分类 -->
|
|
|
- <view class="custom-class-box" v-else-if="item.type == 'customClass'"
|
|
|
- :style="{ marginTop: tovw(item.marginTop || 0) }">
|
|
|
- <view class="head">
|
|
|
- <view class="label">
|
|
|
- <text class="must" style="color: #E3041F;" v-if="item.isMust">*</text>
|
|
|
- {{ item.label }}
|
|
|
- </view>
|
|
|
- <view class="state">
|
|
|
- {{ item.isMultipleChoice ? '可多选' : '仅单选' }}
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <view class="options">
|
|
|
- <view class="option"
|
|
|
- :class="item.isMultipleChoice ? (item.value.includes(option.value) ? 'active' : '') : (item.value == option.value ? 'active' : '')"
|
|
|
- v-for=" option in item.list " :key="option.value" hover-class="navigator-hover"
|
|
|
- @click="changOptions(option.value, index)">
|
|
|
- {{ option.remarks }}
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <!-- 选择所在地区 -->
|
|
|
- <picker class="region" @change="selectRegion($event, index)" mode='region' :disabled="item.disabled"
|
|
|
- :value="item.value" v-else-if="item.type == 'region'"
|
|
|
- :style="{ marginTop: tovw(item.marginTop || 0), opacity: item.disabled ? 0.7 : 1 }">
|
|
|
- <view class="box" :class="item.unBorBot ? '' : 'borBot'">
|
|
|
- <view class="label">
|
|
|
- <text class="must" v-if="item.isMust">*</text>
|
|
|
- {{ item.label }}:
|
|
|
- </view>
|
|
|
- <view class="content-box">
|
|
|
- <view class="value" v-if="item.value.length">
|
|
|
- {{ item.value.join(",") }}
|
|
|
- </view>
|
|
|
- <view v-else class="placeholder" hover-class="none">
|
|
|
- {{ item.placeholder || '请选择' + item.label }}
|
|
|
- </view>
|
|
|
- <view v-if="!item.disabled" class="iconfont icon-a-wodetiaozhuan" />
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </picker>
|
|
|
- <!-- 日期 -->
|
|
|
- <picker class="region" @change="selectRegion($event, index)" mode='date' :disabled="item.disabled"
|
|
|
- :value="item.value" v-else-if="item.type == 'date'"
|
|
|
- :style="{ marginTop: tovw(item.marginTop || 0), opacity: item.disabled ? 0.7 : 1 }">
|
|
|
- <view class="box" :class="item.unBorBot ? '' : 'borBot'">
|
|
|
- <view class="label">
|
|
|
- <text class="must" v-if="item.isMust">*</text>
|
|
|
- {{ item.label }}:
|
|
|
- </view>
|
|
|
- <view class="content-box">
|
|
|
- <view class="value" v-if="item.value">
|
|
|
- {{ item.value }}
|
|
|
- </view>
|
|
|
- <view v-else class="placeholder" hover-class="none">
|
|
|
- {{ item.placeholder || '请选择' + item.label }}
|
|
|
- </view>
|
|
|
- <view v-if="!item.disabled" class="iconfont icon-a-wodetiaozhuan" />
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </picker>
|
|
|
- <!-- 上传附件 -->
|
|
|
- <view class="custom-class-box" v-else-if="item.type == 'upload'"
|
|
|
- :style="{ marginTop: tovw(item.marginTop || 0) }">
|
|
|
- <view class="head">
|
|
|
- <view class="label">
|
|
|
- <text class="must" v-if="item.isMust">*</text>
|
|
|
- {{ item.label }}
|
|
|
- </view>
|
|
|
- <view class="state">
|
|
|
- {{ item.placeholder }}
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <view class="content">
|
|
|
- <view class="file-box" v-for="file in item.value" :key="file.attachmentid">
|
|
|
- <image class="image" v-if="file.fileType == 'image'" :src="file.url" mode="aspectFill"
|
|
|
- lazy-load="true" @click="previewImg(file)" />
|
|
|
- <video v-else-if="file.fileType == 'video'" class="video" :poster="file.subfiles[0].url"
|
|
|
- :src="file.url" />
|
|
|
- <image class="delete" @click.stop="deleteFile(file, index)"
|
|
|
- src="https://yossys06593.obs.cn-east-3.myhuaweicloud.com:443/202404241713944430197B47af9b2f.png"
|
|
|
- mode="widthFix" />
|
|
|
- </view>
|
|
|
- <My_upload v-if="item.allowUpload" :showLoading="false" :accept="item.accept"
|
|
|
- @uploadCallback="uploadCallback($event, index)" @onLoading="onUploadLoading($event, index)">
|
|
|
- <view class="upload-box" hover-class="navigator-hover">
|
|
|
- <u-loading-icon v-if="item.loading" />
|
|
|
- <text v-else class="iconfont icon-xiazai" />
|
|
|
- <text style="margin-left: 5px;">上传</text>
|
|
|
- </view>
|
|
|
- </My_upload>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <!-- 开关 -->
|
|
|
- <view class="region" v-else-if="item.type == 'switch'">
|
|
|
- <view class="box" :class="item.unBorBot ? '' : 'borBot'">
|
|
|
- <view class="label">
|
|
|
- <text class="must" v-if="item.isMust">*</text>
|
|
|
- {{ item.label }}:
|
|
|
- </view>
|
|
|
- <view class="content-box">
|
|
|
- <view />
|
|
|
- <u-switch activeColor="#70D95D" v-model="item.value" :disabled="item.disabled"
|
|
|
- @change="switchChange($event, index)" />
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <!-- 性别 -->
|
|
|
- <view class="region" v-else-if="item.type == 'sex'">
|
|
|
- <view class="box" :class="item.unBorBot ? '' : 'borBot'">
|
|
|
- <view class="label">
|
|
|
- <text class="must" v-if="item.isMust">*</text>
|
|
|
- {{ item.label }}:
|
|
|
- </view>
|
|
|
- <u-radio-group v-model="item.value" placement="row" @change="groupChange($event, index)">
|
|
|
- <u-radio :customStyle="{ marginRight: tovw(60) }" label="男" name="男" />
|
|
|
- <u-radio label="女" name="女" />
|
|
|
- </u-radio-group>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
<!-- 单选 -->
|
|
|
<view class="region" v-else-if="item.type == 'radio'">
|
|
|
<view class="box" :class="item.unBorBot ? '' : 'borBot'">
|
|
@@ -196,33 +69,13 @@
|
|
|
</u-radio-group>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <!-- 路由选择器 -->
|
|
|
- <view class="region" v-else-if="item.type == 'route'"
|
|
|
- :style="{ marginTop: tovw(item.marginTop || 0), opacity: item.disabled ? 0.7 : 1 }"
|
|
|
- @click="item.disabled ? '' : toRoute(item, index)">
|
|
|
- <view class="box" :class="item.unBorBot ? '' : 'borBot'">
|
|
|
- <view class="label">
|
|
|
- <text class="must" v-if="item.isMust">*</text>
|
|
|
- {{ item.label }}:
|
|
|
- </view>
|
|
|
- <view class="content-box">
|
|
|
- <view class="value" v-if="item.value.length">
|
|
|
- {{ item.showValue.join(",") }}
|
|
|
- </view>
|
|
|
- <view v-else class="placeholder" hover-class="none">
|
|
|
- {{ item.placeholder || '请选择' + item.label }}
|
|
|
- </view>
|
|
|
- <view v-if="!item.disabled" class="iconfont icon-a-wodetiaozhuan" />
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
</block>
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { formattedFiles, viewImage } from "../../utils/settleFiles.js"
|
|
|
+import { formattedFiles, viewImage } from "../utils/settleFiles.js"
|
|
|
|
|
|
export default {
|
|
|
name: "my_form",
|
|
@@ -271,70 +124,8 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
async created() {
|
|
|
- /* let list = [{
|
|
|
- key: "name",
|
|
|
- type: "text",
|
|
|
- label: "标题",
|
|
|
- isMust: true,//是否必填
|
|
|
- value: "",
|
|
|
- inputmode:"", //https://uniapp.dcloud.net.cn/component/input.html#type
|
|
|
- marginTop: 10,
|
|
|
- verify:[],
|
|
|
- }, {
|
|
|
- key: "Class",
|
|
|
- type: "customClass",
|
|
|
- label: "标题",
|
|
|
- isMust: false,//是否必填
|
|
|
- isMultipleChoice: true,//是否多选
|
|
|
- value: [],// 多选[] 单选 ""
|
|
|
- isMust: true,//是否必填
|
|
|
- list: await this.getCustomClass('picturespace'),
|
|
|
- marginTop: 10
|
|
|
- },{
|
|
|
- key: "attachmentids",
|
|
|
- type: "upload",
|
|
|
- label: "图片/视频",
|
|
|
- accept:"all",
|
|
|
- placeholder: "可上传多个视频或图片",
|
|
|
- ownertable: "temporary",
|
|
|
- ownerid: 999,
|
|
|
- usetype: 'default',
|
|
|
- allowUpload: true,
|
|
|
- allowDelete: true,
|
|
|
- value:[],
|
|
|
- marginTop: 10
|
|
|
- }, {
|
|
|
- key: "region",
|
|
|
- type: "region",
|
|
|
- label: "所在地区",
|
|
|
- isMust: true,//是否必填
|
|
|
- value: [],
|
|
|
- }, {
|
|
|
- key: "address",
|
|
|
- type: "textarea",
|
|
|
- label: "详细地址",
|
|
|
- isMust: true,//是否必填
|
|
|
- value: '',
|
|
|
- }, {
|
|
|
- key: "isdefault",
|
|
|
- type: "switch",
|
|
|
- label: "设为默认地址",
|
|
|
- isMust: false,//是否必填
|
|
|
- value: false,
|
|
|
- isNum: true,
|
|
|
- unBorBot: true
|
|
|
- }] */
|
|
|
},
|
|
|
methods: {
|
|
|
- toRoute(item, index) {
|
|
|
- uni.navigateTo({
|
|
|
- url: item.path
|
|
|
- });
|
|
|
- this.$Http.routeSelected = function (selected) {
|
|
|
- this.$emit('interrupt', item, selected, index)
|
|
|
- delete this.$Http.routeSelected;
|
|
|
- }.bind(this)
|
|
|
- },
|
|
|
onInput(e, index) {
|
|
|
let item = this.list[index];
|
|
|
item.errText = "";
|
|
@@ -365,25 +156,6 @@ export default {
|
|
|
this.$set(this.list[index], 'value', e)
|
|
|
this.verify()
|
|
|
},
|
|
|
- changOptions(value, index) {
|
|
|
- let item = this.list[index];
|
|
|
- if (item.isMultipleChoice) {
|
|
|
- let i = -1;
|
|
|
- try {
|
|
|
- i = item.value.findIndex(v => v == value)
|
|
|
- } catch (error) {
|
|
|
- }
|
|
|
- if (i == -1) {
|
|
|
- item.value.push(value)
|
|
|
- } else {
|
|
|
- item.value.splice(i, 1)
|
|
|
- }
|
|
|
- this.$set(this.list[index], 'value', item.value)
|
|
|
- } else {
|
|
|
- this.$set(this.list[index], 'value', value)
|
|
|
- }
|
|
|
- this.verify()
|
|
|
- },
|
|
|
verify() {
|
|
|
let list = this.list.filter(v => v.isMust);
|
|
|
let Uncomplete = false;
|
|
@@ -411,89 +183,6 @@ export default {
|
|
|
previewImg(item) {
|
|
|
viewImage(item.url)
|
|
|
},
|
|
|
- uploadCallback(attachmentids, index) {
|
|
|
- let item = this.list[index];
|
|
|
- this.$Http.basic({
|
|
|
- "classname": "system.attachment.Attachment",
|
|
|
- "method": "createFileLink",
|
|
|
- "content": {
|
|
|
- ownertable: item.ownertable,
|
|
|
- ownerid: item.ownerid,
|
|
|
- usetype: item.usetype,
|
|
|
- attachmentids
|
|
|
- }
|
|
|
- }).then(res => {
|
|
|
- console.log('绑定附件', res)
|
|
|
- if (this.cutoff(res.msg)) return;
|
|
|
- res.data = formattedFiles(res.data)
|
|
|
- item.value.push(res.data[0]);
|
|
|
-
|
|
|
- //临时文件
|
|
|
- if (res.data[0].ownertable == "temporary") try {
|
|
|
- item.temporarys.push(attachmentids[0])
|
|
|
- } catch (error) {
|
|
|
- item.temporarys = [attachmentids[0]]
|
|
|
- }
|
|
|
-
|
|
|
- this.$set(this.list[index], 'value', item.value)
|
|
|
- this.verify()
|
|
|
- })
|
|
|
- },
|
|
|
- deleteFiles() {
|
|
|
- this.list.forEach(v => {
|
|
|
- if (v.type == 'upload') {
|
|
|
- let linksids = v.value.filter(v => v.ownertable == "temporary").map(v => v.linksid)
|
|
|
- if (linksids.length) this.$Http.basic({
|
|
|
- "classname": "system.attachment.Attachment",
|
|
|
- "method": "deleteFileLink",
|
|
|
- "content": {
|
|
|
- linksids
|
|
|
- }
|
|
|
- }).then(res => {
|
|
|
- console.log("处理删除附件", res)
|
|
|
- if (this.cutoff(res.msg)) return;
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- onUploadLoading(e, index) {
|
|
|
- this.$set(this.list[index], 'loading', e)
|
|
|
- this.$emit("onUploading", e)
|
|
|
- },
|
|
|
- groupChange(e, index) {
|
|
|
- this.$set(this.list[index], 'loading', e)
|
|
|
- this.verify()
|
|
|
- },
|
|
|
- selectRegion({ detail }, index) {
|
|
|
- this.$set(this.list[index], 'value', detail.value)
|
|
|
- this.verify()
|
|
|
- },
|
|
|
- deleteFile(flie, index) {
|
|
|
- let item = this.list[index];
|
|
|
- item.value = item.value.filter(v => v.attachmentid != flie.attachmentid)
|
|
|
- //临时文件
|
|
|
- if (flie.ownertable == "temporary") {
|
|
|
- item.temporarys = item.temporarys.filter(v => v != flie.attachmentid)
|
|
|
- this.$Http.basic({
|
|
|
- "classname": "system.attachment.Attachment",
|
|
|
- "method": "deleteFileLink",
|
|
|
- "content": {
|
|
|
- linksids: [flie.linksid]
|
|
|
- }
|
|
|
- }).then(res => {
|
|
|
- console.log("处理删除附件", res)
|
|
|
- if (this.cutoff(res.msg)) return;
|
|
|
- });
|
|
|
- } else {
|
|
|
- try {
|
|
|
- item.linksids.push(flie.linksid)
|
|
|
- } catch (error) {
|
|
|
- item.linksids = [flie.linksid]
|
|
|
- }
|
|
|
- }
|
|
|
- this.$set(this.list[index], 'value', item.value)
|
|
|
- this.verify()
|
|
|
- },
|
|
|
submit() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
let res = {};
|
|
@@ -667,17 +356,6 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-.textarea-box {
|
|
|
- width: 100%;
|
|
|
-
|
|
|
- .textarea {
|
|
|
- width: 355px;
|
|
|
- height: 160px;
|
|
|
- padding: 15px 10px;
|
|
|
- box-sizing: border-box;
|
|
|
- margin: 0 auto;
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
.input-box {
|
|
|
width: 100%;
|
|
@@ -742,14 +420,17 @@ export default {
|
|
|
align-items: center;
|
|
|
box-sizing: border-box;
|
|
|
position: relative;
|
|
|
- input {
|
|
|
+ input,textarea {
|
|
|
width: 100%;
|
|
|
- height: 50px;
|
|
|
+ height: 50px !important;
|
|
|
background: #F7F7F7;
|
|
|
border-radius: 8px 8px 8px 8px;
|
|
|
border: 1px solid #DDDDDD;
|
|
|
padding-left: 10px;
|
|
|
}
|
|
|
+ textarea {
|
|
|
+ line-height: 50px;
|
|
|
+ }
|
|
|
|
|
|
.icon {
|
|
|
padding: 5px;
|