| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 |
- <template>
- <div class="radioGroup">
- <template v-for="(val, ind) in clueOptionList">
- <!-- <div class="title" v-if="val.customerClueName">
- <span class="van-f-red" v-if="val.isMust == 0">*</span>
- {{ val.customerClueName }}
- </div> -->
- <template v-if="val.answerType == 'dx'">
- <div class="title" v-if="val.customerClueName">
- <span class="van-f-red" v-if="val.isMust == 0">*</span>
- {{ val.customerClueName }}
- </div>
- <van-radio-group v-model="val.searchValue" @change="radioGroupChange">
- <template v-for="(item, index) in val.customerClueOptionList">
- <van-radio :name="item.customerClueOptionId" :key="index" @click="radioClick">
- {{ item.customerClueOption }}
- </van-radio>
- <radioGroup
- :clueOptionList="item.customerClueItemList"
- :parentOptionList="val"
- :parentId="item.customerClueOptionId"
- v-if="val.searchValue == item.customerClueOptionId"></radioGroup>
- </template>
- </van-radio-group>
- </template>
- <!-- 回答类型:wb-文本,sz-数字,rq-日期,zp-照片,dx-单选,bg-表格 -->
- <template v-if="val.answerType == 'wb'">
- <div class="title" v-if="val.customerClueName">
- <span class="van-f-red" v-if="val.isMust == 0">*</span>
- {{ val.customerClueName }}
- </div>
- <template v-if="parentOptionList.searchValue == val.itemOptionParentId">
- <template v-if="val.customerClueName.indexOf('填写服务商代码') != -1">
- <div class="fws">
- <van-field class="fwsLeft" v-model="fws" disabled />
- <van-field
- class="fwsRight"
- v-model="val.answerValue"
- :placeholder="val.remark"
- type="number"
- :class="{
- fieldInput: true,
- rulesClass: val.answerValue != null && val.answerValue.length < val.minTextLength,
- }" />
- </div>
- </template>
- <template v-else>
- <van-field
- v-model="val.answerValue"
- :placeholder="val.remark"
- :minTextLength="val.minTextLength"
- autosize
- type="textarea"
- :class="{
- fieldInput: true,
- rulesClass: val.answerValue != null && val.answerValue.length < val.minTextLength,
- }" />
- </template>
- <span
- class="rulesErrorMessage"
- v-if="val.answerValue != null && val.answerValue.length < val.minTextLength">
- {{ val.remark }}
- </span>
- </template>
- </template>
- <!-- 数字输入框 -->
- <template v-if="val.answerType == 'sz'">
- <div class="title" v-if="val.customerClueName">
- <span class="van-f-red" v-if="val.isMust == 0">*</span>
- {{ val.customerClueName }}
- </div>
- <van-field
- v-if="
- val.customerClueName.indexOf('开户门店代码') != -1 ||
- val.customerClueName.indexOf('开户经销商代码') != -1
- "
- class="fieldInput"
- v-model="val.answerValue"
- :placeholder="val.remark"
- maxlength="10"
- :minTextLength="val.minTextLength"
- type="digit"
- @focus="inputFocus(val)"></van-field>
- <van-field
- v-else
- class="fieldInput"
- v-model="val.answerValue"
- :placeholder="val.remark"
- :minTextLength="val.minTextLength"
- type="number"></van-field>
- </template>
- <!-- 照片 -->
- <template v-if="val.answerType == 'zp'">
- <van-cell>
- <template #title>
- <span v-if="val.isMust == 0" class="van-f-red">*</span>
- {{ val.customerClueName }}
- <!-- 操作说明图片和电话 -->
- <taskTips
- v-if="val.contactPhone || val.examplePhoto"
- :contactPhone="val.contactPhone"
- :examplePhoto="val.examplePhoto">
- </taskTips>
- </template>
- <template #right-icon>
- <span v-if="val.isMust == '0'" style="color: red">图片必填</span>
- <div class="uploadImg">
- <complaintImg
- uploadid="uploadid2"
- :itemData="val"
- @newimgarr="newimgarr1"
- :customerClueId="val.customerClueId"
- :customerClueItemId="val.customerClueItemId"
- :required="false">
- </complaintImg>
- </div>
- <!-- <van-icon color="#666" name="photograph" size="24" @click="imgClick(val)" /> -->
- </template>
- </van-cell>
- <deletComplaintImg :itemData="val" @deleteImg="deleteImg"></deletComplaintImg>
- </template>
- <!-- 表格 -->
- <template v-if="val.answerType == 'bg'">
- <div class="title" v-if="val.customerClueName">
- <span class="van-f-red" v-if="val.isMust == 0">*</span>
- {{ val.customerClueName }}
- </div>
- <el-table :data="val.tableData.data" style="width: 100%; position: relative; left: -10px">
- <el-table-column
- v-for="(item, index) in val.tableData.title"
- :key="index"
- :prop="item.prop"
- :label="item.label"
- align="center">
- <template slot-scope="scope">
- <template v-if="item.answerType == 'text'">
- {{ scope.row[item.prop] }}
- </template>
- <template v-if="item.answerType == 'wb'">
- <van-field v-model="scope.row[item.prop]" />
- </template>
- <!-- 正整数 digit -->
- <template v-if="item.answerType == 'sz'">
- <van-field v-model="scope.row[item.prop]" type="digit" />
- </template>
- </template>
- </el-table-column>
- </el-table>
- </template>
- </template>
- </div>
- </template>
- <script>
- import taskTips from '@/views/deviceWithin/taskTips';
- import deletComplaintImg from '@/components/deletComplaintImg';
- import complaintImg from '@/components/complaintImg';
- export default {
- components: { deletComplaintImg, taskTips, complaintImg },
- name: 'radioGroup',
- props: {
- clueOptionList: {
- type: Array,
- default: () => [],
- },
- parentOptionList: {
- type: Object,
- default: () => {},
- },
- parentId: {
- type: [Number, null],
- default: null,
- },
- },
- data() {
- return {
- fws: 'FSQ',
- };
- },
- watch: {
- clueOptionList: {
- handler(val) {
- val.forEach((item) => {
- // bg表格数据存在remark
- if (item.answerType == 'bg') {
- this.$set(item, 'tableData', JSON.parse(item.remark));
- }
- });
- },
- immediate: true,
- },
- },
- created() {
- // console.log(this.clueOptionList);
- },
- methods: {
- radioGroupChange(name) {
- if (!name) return;
- // console.log(name);
- // console.log(this.clueOptionList);
- // 如果选中的数据有父级,将父级数据修改为选中状态
- if (this.parentOptionList && this.parentId) {
- this.$set(this.parentOptionList, 'searchValue', this.parentId);
- }
- // 获取选中数据
- let clueOptionList = this.clueOptionList.find((val) => val.searchValue == name);
- let activaRadio = clueOptionList.customerClueOptionList.find(
- (val) => val.customerClueOptionId == name
- );
- // 修改选中状态
- this.$set(activaRadio, 'value', 'Y');
- // 过滤未选中的数据
- let exceptItself = clueOptionList.customerClueOptionList.filter(
- (val) => val.customerClueOptionId !== name
- );
- // 删除未选中数据状态兄弟级和子级
- // console.log(exceptItself);
- this.toggleOtheChildren(exceptItself);
- },
- toggleOtheChildren(exceptItself) {
- if (!exceptItself) return;
- exceptItself.forEach((val) => {
- this.$set(val, 'value', 'N');
- if (val.customerClueItemList && val.customerClueItemList[0]) {
- this.$set(val.customerClueItemList[0], 'searchValue', null);
- if (
- val.customerClueItemList[0] &&
- val.customerClueItemList[0].customerClueOptionList.length
- ) {
- this.toggleOtheChildren(val.customerClueItemList[0].customerClueOptionList);
- }
- }
- });
- },
- radioClick(event) {
- // console.log(event);
- },
- imgClick(val) {
- this.show = true;
- },
- // 设置照片数据
- newimgarr1(val) {
- console.log(val);
- let fileInfoList = [{ fileUrl: val.fileUrl, id: val.id }].concat(
- val.itemData.fileInfoList ? val.itemData.fileInfoList : []
- );
- this.$set(val.itemData, 'fileInfoList', fileInfoList);
- this.setFileIdList(val);
- },
- // 设置照片id
- setFileIdList(val) {
- let fileIdList = [];
- let fileInfoList = val.itemData.fileInfoList || [];
- fileInfoList.forEach((val) => {
- fileIdList.push(val.id);
- });
- this.$set(val.itemData, 'fileIdList', fileIdList);
- },
- // 删除照片
- deleteImg(val) {
- val.itemData.fileInfoList.splice(val.index, 1);
- this.setFileIdList(val);
- },
- // 设置输入框长度限制
- inputFocus(val) {
- if (val.minTextLength) return;
- this.$set(val, 'minTextLength', 10);
- },
- },
- };
- </script>
- <style lang="scss">
- .radioGroup {
- font-size: 15px;
- .van-radio {
- padding: 5px 0;
- }
- .van-radio-group {
- padding-left: 20px;
- }
- .van-cell {
- padding: 10px 0;
- /* font-size: 14px; */
- }
- .van-cell::after {
- border: 0;
- }
- .van-field {
- padding: 0;
- width: 97%;
- border-radius: 4px;
- overflow: hidden;
- background-color: unset;
- // height: 30px;
- // line-height: 30px;
- border: 1px solid #cdc8c8;
- }
- .van-field__control {
- /* padding: 0 10px; */
- /* margin: 5px 0; */
- padding-left: 10px;
- }
- .van-radio__label {
- /* font-size: 14px; */
- }
- .van-f-red {
- font-size: 14px;
- }
- .rulesClass {
- border: 1px solid #ff0505;
- }
- .fieldInput {
- /* height: 38px; */
- }
- .rulesErrorMessage {
- color: red;
- font-size: 12px;
- padding: 3px 0;
- }
- .uploadImg {
- width: 50px;
- }
- .el-table {
- .el-table__cell {
- padding: 3px 0;
- }
- }
- .fws {
- display: flex;
- flex-direction: row;
- width: 90%;
- padding: 5px 0;
- .fwsLeft {
- width: 50px;
- font-weight: 600;
- color: #000;
- }
- }
- }
- </style>
|