Lou
2024-04-22 bbcb300bb30e287816c6f1e6aff96aa0fd0e1c91
subPackage/school/trouble.vue
@@ -4,54 +4,14 @@
         <u-form labelPosition="left" :model="info" :rules="rules" ref="form" labelWidth="90"
            :labelStyle="{fontSize:'28rpx'}">
            <u-form-item label="类型:" labelWidth="100" prop="type" :required="isRequired">
               <u-radio-group v-model="info.type">
                  <u-radio :customStyle="{marginBottom: '8px'}" v-for="(item, index) in statusList" :key="index"
                     :label="item.name" :name="item.id">
                  </u-radio>
               </u-radio-group>
            <u-form-item label="隐患类型" prop="hiddenDangerType" borderBottom ref="phone" v-if="info.type == 1"
               @click="showPicker = true">
               <u-input v-model="info.hiddenDangerType" border="none" placeholder="请输入"
                  placeholderClass="f-28 c-99" inputAlign="right" disabled disabledColor="#ffffff"></u-input>
               <u-icon slot="right" name="arrow-right"></u-icon>
            </u-form-item>
            <u-form-item label="家长姓名" prop="name" borderBottom ref="name" required>
               <u-input v-model="info.name" border="none" placeholder="请输入" placeholderClass="f-28 c-99"
                  inputAlign="right"></u-input>
            </u-form-item>
            <u-form-item label="家长手机号" prop="phone" borderBottom ref="phone" required>
               <u-input v-model="info.phone" border="none" placeholder="请输入" placeholderClass="f-28 c-99"
                  inputAlign="right"></u-input>
            </u-form-item>
            <u-form-item label="学生姓名" prop="realName" borderBottom ref="realName" required>
               <u-input v-model="info.realName" border="none" placeholder="请输入" placeholderClass="f-28 c-99"
                  inputAlign="right"></u-input>
            </u-form-item>
            <u-form-item label="学生班级" prop="gradeAndClass" borderBottom ref="gradeAndClass" required>
               <u-input v-model="info.gradeAndClass" border="none" placeholder="请输入" placeholderClass="f-28 c-99"
                  inputAlign="right"></u-input>
            </u-form-item>
            <u-form-item label="位置" prop="location" :borderBottom="false" required>
               <view class="address-row flex">
                  <view class="address-content f-28" v-if="info.location">
                     {{info.location}}
                  </view>
                  <view class="address-content f-28 c-99" v-if="!info.location">
                     请选择地址
                  </view>
                  <view class="location-btn c-main f-24" @click="getLocation()">
                     获取地址
                  </view>
               </view>
               <!-- <u-input v-model="info.address" border="none"  placeholderClass="f-28 c-99"
                  inputAlign="right"    disabled  disabledColor="#fff">
                  <template slot="suffix">
                     <button class="location-btn c-main f-24"   @click="getLocation()">获取地址</button>
                  </template>
               </u-input> -->
            </u-form-item>
            <u-form-item label="描述" prop="describe" borderBottom ref="describe" required>
               <u-textarea v-model="info.describe" border="none" placeholder="请输入" placeholderClass="f-28 c-99"
            <u-form-item label="描述" prop="remark" borderBottom ref="remark" required>
               <u-textarea v-model="info.remark" border="none" placeholder="请输入" placeholderClass="f-28 c-99"
                  inputAlign="right"></u-textarea>
            </u-form-item>
         </u-form>
@@ -74,7 +34,13 @@
      <button class="submit-btn" @click="sumitInfo">提交</button>
      <!-- <button class="list-btn" @click="navigatorPage">我上报的事件</button> -->
      <button class="list-btn" @click="navigatorPage">提交记录</button>
      <u-picker :defaultIndex="troubleTypeIndex" :closeOnClickOverlay="true" :show="showPicker"
         :columns="[troubleTypeList]" @close="showPicker = false" @cancel="showPicker = false" keyName="name"
         @confirm="confirmPicker"></u-picker>
   </view>
</template>
@@ -82,66 +48,46 @@
<script>
   import uploadMixin from "@/mixin/uploadMixin";
   import {
      addClockIn
      addTroubleReport
   } from "@/api/school/school.js";
   import {
      bizDictionary,
      bizDictionaryTree
   } from '@/api/system/dict.js'
   export default {
      mixins: [uploadMixin],
      data() {
         return {
            form: {
               images: []
            },
            info: {
               name: "",
               phone: "",
               location: "",
               gradeAndClass: ""
               type: "",
               hiddenDangerType: "",
               remark: ""
            },
            rules: {
               'name': {
               'remark': {
                  type: 'string',
                  required: true,
                  message: '请输入家长姓名',
                  trigger: ['blur', 'change']
               },
               'phone': [{
                     type: 'string',
                     required: true,
                     message: '请输入手机号',
                     trigger: ['blur', 'change']
                  },
                  {
                     validator: (rule, value, callback) => {
                        return uni.$u.test.mobile(value);
                     },
                     message: '手机号码不正确',
                     trigger: ['change', 'blur']
                  }
               ],
               'location': {
                  type: 'string',
                  required: true,
                  message: '请选择地址',
                  trigger: ['blur', 'change']
               },
            },
            desc: "",
            title: "",
            curSelectSite: {},
            statusList: [{
                  name: "隐患",
                  id: 1
               },
               {
                  name: "矛盾",
                  id: 2
               }
            ],
            troubleTypeList: [],
            troubleTypeIndex: [0],
            showPicker: false
         }
      },
      onLoad(option) {
         if (option.type) {
            this.info.type = option.type
         }
         this.getAllBizDict()
      },
      // onShow() {
      //    this.curSelectSite = uni.getStorageSync('siteInfo')
@@ -149,19 +95,36 @@
      // },
      methods: {
         getLocation() {
            uni.chooseLocation({
               success: (res) => {
                  this.$set(this.info, "location", res.address);
                  // this.$set(this.info, "lat", res.latitude);
                  // this.$set(this.info, "lng", res.longitude)
               }
         async getAllBizDict() {
            //反诈类别
            await this.getBizDict('hiddenDangerType', this.troubleTypeList);
         },
         // 获取业务字典
         async getBizDict(code, list) {
            const param = {
               code: code
            }
            const res = await bizDictionary(param)
            res.data.forEach(e => {
               list.push({
                  name: e.dictValue,
                  value: Number(e.dictKey)
               })
            })
         },
         sumitInfo() {
         //选择隐患类型
         confirmPicker(e) {
            this.genderIndex = e.indexs;
            this.genderValue = e.value[0].name;
            this.info.hiddenDangerType = e.value[0].value;
            this.showPicker = false;
         },
         sumitInfo() {
            this.$refs.form.validate().then(valid => {
               if (this.form.images.length > 0) {
                  let urls = []
@@ -170,7 +133,7 @@
                  })
                  this.info.images = urls.join(",")
               }
               addClockIn(this.info).then(res => {
               addTroubleReport(this.info).then(res => {
                  this.$showTips("提交成功", "success")
                  setTimeout(() => {
                     uni.navigateBack()
@@ -179,7 +142,7 @@
            })
         },
         navigatorPage() {
            let url = "/subPackage/bs/views/repairList" + "?title=" + this.title + "&type=" + this.info.type
            let url = `troubleList?type=${this.info.type}`
            this.$u.func.globalNavigator(url, "navTo")
         }
      }