408249787@qq.com 2 днів тому
батько
коміт
f59ffac5a2

+ 17 - 1
api/sb/info.js

@@ -20,7 +20,7 @@ export function getSbInfoPage(parameter) {
 /**
  * 更新设备图片
  */
-export function updateSbInfoImages (parameter) {
+export function updateSbInfoImages(parameter) {
     return http({
         url: '/sb/infos/images/' + parameter.id,
         method: 'PUT',
@@ -248,3 +248,19 @@ export function getPartInfoPositionPage(parameter) {
         }
     });
 }
+
+/**
+ * 获取设备位置树
+ * parameter: { }
+ * @param parameter :
+ * @returns {*}
+ */
+export function getSbPositionTree(parameter) {
+    return http({
+        url: '/sb/positions/tree?' + stringify(parameter),
+        method: 'get',
+        headers: {
+            'Content-Type': 'application/json;charset=UTF-8'
+        }
+    })
+}

+ 358 - 0
components/tree-select/tree-select.vue

@@ -0,0 +1,358 @@
+<template>
+  <view class="width-100">
+    <view class="d-flex a-center" style="width:100%">
+      <view @click="openPopup" class="d-flex px2" style="width:100%">
+        <view class="input-box flex1">
+          <view v-if="inputLabel" class="text-color-3">{{ inputLabel }}</view>
+          <view v-else class="text-color-9">{{ placeholder }}</view>
+        </view>
+        <u-icon name="arrow-right"></u-icon>
+      </view>
+    </view>
+    <u-popup mode="bottom" v-model="showPopup" length="auto" :safeAreaInsetBottom="true" :maskCloseAble="true">
+      <view class="ts-popup">
+        <view class="ts-header" @touchmove.stop.prevent="">
+          <view class="ts-btn ts-btn--cancel" hover-class="ts-opacity" :hover-stay-time="150" @tap="handleCancel">取消
+          </view>
+          <view class="ts-title">{{ title }}</view>
+          <view class="ts-btn ts-btn--confirm" hover-class="ts-opacity" :hover-stay-time="150" @tap="handleConfirm">确认
+          </view>
+        </view>
+        <scroll-view scroll-y class="ts-body">
+          <view v-for="(item, index) in visibleNodes" :key="index" class="ts-item"
+            :class="{ 'ts-item--active': tempValue === item.node[valueName] }"
+            :style="{ paddingLeft: item.depth * 40 + 30 + 'rpx' }" @click="selectNode(item)">
+            <view class="ts-item-label">{{ item.node[labelName] }}</view>
+            <u-icon v-if="tempValue === item.node[valueName]" name="checkmark" size="28" color="#0082ff"></u-icon>
+            <view v-if="hasChildren(item.node)" class="ts-arrow" @click.stop="toggleExpand(item.node)">
+              <u-icon :name="isExpanded(item.node) ? 'arrow-down' : 'arrow-right'" size="26" color="#909399"></u-icon>
+            </view>
+          </view>
+          <view v-if="!visibleNodes.length" class="ts-empty">暂无数据</view>
+        </scroll-view>
+      </view>
+    </u-popup>
+  </view>
+</template>
+
+<script>
+import Emitter from '@/uview-ui/libs/util/emitter.js'
+
+/**
+ * treeSelect 树形选择表单组件
+ * @description 外观与 my-select 一致的表单选择框,点击后从底部弹出树形选择面板:
+ *              父节点可通过右侧箭头展开/收起子级,点击任意节点(父/子)即选中,
+ *              点击“确认”后写回 v-model,并派发 u-form 校验事件。
+ * @property {String Number} value 选中节点的值(v-model)
+ * @property {Array} data 树形数据,形如 [{ id, title, children: [...] }]
+ * @property {Array} list 树形数据(data 的别名,兼容旧用法)
+ * @property {String} labelName 节点显示文本对应的字段名(默认title)
+ * @property {String} valueName 节点值对应的字段名(默认id)
+ * @property {String} childrenName 子节点数组对应的字段名(默认children)
+ * @property {String} placeholder 未选中时的占位文案(默认请选择)
+ * @property {String} title 弹出面板顶部标题(默认请选择)
+ * @property {Boolean} disabled 是否禁用选择(默认false)
+ * @event {Function} input 确认选中后触发(v-model)
+ * @event {Function} selected 确认选中后触发,返回 (value, 节点对象)
+ * @example <tree-select v-model="form.sbCph" :data="sbPositionData" />
+ */
+export default {
+  name: 'TreeSelect',
+  mixins: [Emitter],
+  props: {
+    // 选中节点的值(v-model)
+    value: {
+      type: [String, Number],
+      default: ''
+    },
+    // 树形数据
+    data: {
+      type: Array,
+      default() {
+        return []
+      }
+    },
+    // 树形数据(data 的别名)
+    list: {
+      type: Array,
+      default() {
+        return []
+      }
+    },
+    // 显示文本字段名
+    labelName: {
+      type: String,
+      default: 'title'
+    },
+    // 值字段名
+    valueName: {
+      type: String,
+      default: 'id'
+    },
+    // 子节点字段名
+    childrenName: {
+      type: String,
+      default: 'children'
+    },
+    placeholder: {
+      type: String,
+      default: '请选择'
+    },
+    title: {
+      type: String,
+      default: '请选择'
+    },
+    disabled: {
+      type: [String, Number, Boolean],
+      default: false
+    }
+  },
+  data() {
+    return {
+      showPopup: false,
+      inputLabel: '',
+      // 弹框内临时选中的值与文本,确认后才写回
+      tempValue: '',
+      tempLabel: '',
+      // 弹框内已展开的节点 value 集合
+      expandedKeys: []
+    }
+  },
+  computed: {
+    treeData() {
+      return this.data && this.data.length ? this.data : this.list
+    },
+    // 将树按展开状态拍平为可见节点列表:[{ node, depth }]
+    visibleNodes() {
+      const result = []
+      const walk = (nodes, depth) => {
+        if (!nodes || !nodes.length) return
+        for (let i = 0; i < nodes.length; i++) {
+          const node = nodes[i]
+          result.push({ node, depth })
+          if (this.isExpanded(node) && this.hasChildren(node)) {
+            walk(node[this.childrenName], depth + 1)
+          }
+        }
+      }
+      walk(this.treeData, 0)
+      return result
+    }
+  },
+  watch: {
+    value() {
+      this.initByValue()
+    },
+    treeData() {
+      this.initByValue()
+    }
+  },
+  created() {
+    this.$nextTick(() => {
+      this.initByValue()
+    })
+  },
+  methods: {
+    openPopup() {
+      if (this.disabled) {
+        uni.showToast({ title: '不允许选择', icon: 'none' })
+        return
+      }
+      // 回显当前值:临时选中 + 自动展开其所有父级
+      this.tempValue = this.value
+      this.tempLabel = this.inputLabel
+      const path = this.findPath(this.treeData, this.value) || []
+      const keys = []
+      let nodes = this.treeData
+      for (let i = 0; i < path.length - 1; i++) {
+        keys.push(nodes[path[i]][this.valueName])
+        nodes = nodes[path[i]][this.childrenName]
+      }
+      this.expandedKeys = keys
+      this.showPopup = true
+    },
+    handleCancel() {
+      this.showPopup = false
+    },
+    handleConfirm() {
+      const found = this.findNodeByValue(this.treeData, this.tempValue)
+      if (this.tempValue !== '' && this.tempValue !== null && this.tempValue !== undefined && found) {
+        this.inputLabel = found[this.labelName]
+        if (found[this.valueName] + '' !== this.value + '') {
+          this.$emit('input', found[this.valueName])
+          this.$emit('selected', found[this.valueName], found)
+          this.dispatch('u-form-item', 'on-form-change')
+        }
+      }
+      this.showPopup = false
+    },
+    // 点击节点:选中;若为父节点则同时展开其子级,方便继续选子选项
+    selectNode(item) {
+      this.tempValue = item.node[this.valueName]
+      this.tempLabel = item.node[this.labelName]
+      if (this.hasChildren(item.node) && !this.isExpanded(item.node)) {
+        this.expandedKeys = [...this.expandedKeys, item.node[this.valueName]]
+      }
+    },
+    // 点击箭头:仅展开/收起,不改变选中
+    toggleExpand(node) {
+      const key = node[this.valueName]
+      if (this.isExpanded(node)) {
+        this.expandedKeys = this.expandedKeys.filter(k => k !== key)
+      } else {
+        this.expandedKeys = [...this.expandedKeys, key]
+      }
+    },
+    isExpanded(node) {
+      return this.expandedKeys.indexOf(node[this.valueName]) !== -1
+    },
+    hasChildren(item) {
+      const children = item[this.childrenName]
+      return !!(children && children.length)
+    },
+    // 递归查找 value 对应节点,返回 { path, node }
+    findNode(nodes, path = []) {
+      if (this.value === '' || this.value === null || this.value === undefined) {
+        return null
+      }
+      return this.findNodeByValue(nodes, this.value, path)
+    },
+    // 递归查找 value 对应节点的下标路径
+    findPath(nodes, val, path = []) {
+      if (!nodes || !nodes.length || val === '' || val === null || val === undefined) {
+        return null
+      }
+      for (let i = 0; i < nodes.length; i++) {
+        const node = nodes[i]
+        if (node[this.valueName] == val) {
+          return [...path, i]
+        }
+        const children = node[this.childrenName]
+        if (children && children.length) {
+          const found = this.findPath(children, val, [...path, i])
+          if (found) return found
+        }
+      }
+      return null
+    },
+    // 按给定值递归查找节点
+    findNodeByValue(nodes, val, path = []) {
+      if (!nodes || !nodes.length || val === '' || val === null || val === undefined) {
+        return null
+      }
+      for (let i = 0; i < nodes.length; i++) {
+        const node = nodes[i]
+        if (node[this.valueName] == val) {
+          return node
+        }
+        const children = node[this.childrenName]
+        if (children && children.length) {
+          const found = this.findNodeByValue(children, val, [...path, i])
+          if (found) return found
+        }
+      }
+      return null
+    },
+    // 根据外部传入的 value 回显输入框文本
+    initByValue() {
+      const found = this.findNode(this.treeData)
+      this.inputLabel = found ? found[this.labelName] : ''
+    }
+  }
+}
+</script>
+
+<style scoped>
+.width-100 {
+  width: 100%;
+}
+
+.ts-popup {
+  background-color: #fff;
+}
+
+.ts-header {
+  width: 100%;
+  height: 90rpx;
+  padding: 0 40rpx;
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  box-sizing: border-box;
+  font-size: 30rpx;
+  background: #fff;
+  position: relative;
+}
+
+.ts-header::after {
+  content: '';
+  position: absolute;
+  border-bottom: 1rpx solid #eaeef1;
+  -webkit-transform: scaleY(0.5);
+  transform: scaleY(0.5);
+  bottom: 0;
+  right: 0;
+  left: 0;
+}
+
+.ts-title {
+  color: #606266;
+}
+
+.ts-btn {
+  padding: 16rpx;
+  box-sizing: border-box;
+  text-align: center;
+}
+
+.ts-btn--cancel {
+  color: #606266;
+}
+
+.ts-btn--confirm {
+  color: #2979ff;
+}
+
+.ts-opacity {
+  opacity: 0.5;
+}
+
+.ts-body {
+  max-height: 600rpx;
+  padding-bottom: 20rpx;
+}
+
+.ts-item {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  padding-top: 20rpx;
+  padding-bottom: 20rpx;
+  padding-right: 30rpx;
+  font-size: 28rpx;
+  color: #303133;
+}
+
+.ts-item--active {
+  color: #0082ff;
+  font-weight: 600;
+}
+
+.ts-item-label {
+  flex: 1;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+}
+
+.ts-arrow {
+  padding: 6rpx 10rpx;
+}
+
+.ts-empty {
+  text-align: center;
+  color: #909399;
+  font-size: 26rpx;
+  padding: 40rpx 0;
+}
+</style>

Різницю між файлами не показано, бо вона завелика
+ 404 - 380
pages.json


+ 149 - 103
pages/middle/middle.vue

@@ -5,51 +5,23 @@
             <u-form :model="form" ref="uForm">
                 <u-form-item label="选择设备" required prop="running" :label-width="150">
                     <u-input v-model="form.running" disabled @click="handleSelect" placeholder="请选择设备" type="select" />
+
+                    <!--   <u-select
+            v-model="haltState"
+            :list="runningList"
+            @confirm="runningSubmit"
+          ></u-select> -->
                 </u-form-item>
                 <common-popup :list="runningList" @select="runningSubmit" ref="popup" />
                 <view class="main-color-text f-size-32 f-weight-6 mt-2">基本信息</view>
-                <u-form-item label="设备新号" required :label-width="150">
-                    <u-input v-model="form.no" @blur="sbNoBlur($event)" />
-                </u-form-item>
                 <u-form-item label="设备名称" :label-width="150">
                     <u-input v-model="form.sbName" disabled />
                 </u-form-item>
-                <u-form-item label="使用位置" prop="sbCph" required :label-width="150">
-                    <u-input v-model="form.sbCph" :cursor-spacing="cursorSpacing" />
+                <u-form-item label="设备编号" :label-width="150">
+                    <u-input v-model="form.bianhao" disabled />
                 </u-form-item>
-                <u-form-item label="报修人" required :label-width="150">
-                    <u-input v-model="form.actualUser" />
-                </u-form-item>
-                <!-- <u-form-item label="工单类别" required prop="category" :label-width="150">
-                    <u-input v-model="category" disabled @click="badState = true" type="select" />
-                    <u-select v-model="badState" :list="categoryMap" @confirm="badSubmit"></u-select>
-                </u-form-item> -->
                 <view class="main-color-text f-size-32 f-weight-6 mt-2">报修信息</view>
-                <!--                <u-form-item
-                    label="是否停机"
-                    required
-                    prop="halt"
-                    :label-width="150"
-                >
-                    <u-input
-                        v-model="form.halt"
-                        disabled
-                        @click="haltState = true"
-                        placeholder="请选择是否停机"
-                        type="select"
-                    />
-                    <u-select
-                        v-model="haltState"
-                        :list="haltList"
-                        @confirm="haltSubmit"
-                        :default-value="haltDefaultValue"
-                    ></u-select>
-                </u-form-item>-->
-                <!--                <u-form-item
-                    label="报修来源"
-                    prop="repair"
-                    :label-width="150"
-                >
+                <!--                <u-form-item label="报修来源" prop="repair" required :label-width="150">
                     <u-input
                         v-model="form.repair"
                         disabled
@@ -63,13 +35,8 @@
                         @confirm="repairSubmit"
                     ></u-select>
                 </u-form-item>-->
-
-                <!--                <u-form-item
-                    label="紧急等级"
-                    prop="level"
-                    required
-                    :label-width="150"
-                >
+                <!--                
+                <u-form-item label="紧急等级" prop="level" required :label-width="150">
                     <u-input
                         v-model="form.level"
                         disabled
@@ -82,32 +49,55 @@
                         :list="levelList"
                         @confirm="levelSubmit"
                     ></u-select>
-                </u-form-item>-->
+                </u-form-item>
 
-                <!--                <u-form-item
-                    label="故障类别"
+                <u-form-item label="故障类别" required prop="badType" :label-width="150">
+                    <u-input v-model="form.badType" disabled @click="badState = true" type="select" />
+                    <u-select v-model="badState" :list="badList" @confirm="badSubmit"></u-select>
+                </u-form-item>-->
+                <!-- <u-form-item
+                    label="工单类别"
                     required
-                    prop="badType"
+                    prop="category"
                     :label-width="150"
                 >
                     <u-input
-                        v-model="form.badType"
+                        v-model="category"
                         disabled
                         @click="badState = true"
                         type="select"
                     />
                     <u-select
                         v-model="badState"
-                        :list="badList"
+                        :list="categoryMap"
                         @confirm="badSubmit"
                     ></u-select>
-                </u-form-item>-->
-                <u-form-item label="故障描述" :label-width="150">
+                </u-form-item> -->
+                <u-form-item label="使用位置" prop="sbCph" required :label-width="150">
+                    <tree-select v-model="form.sbCph" valueName="title" :data="sbPositionData"></tree-select>
+                </u-form-item>
+                <u-form-item label="是否停机" required prop="needStop" :label-width="150">
+                    <!-- <u-input v-model="form.halt" disabled @click="haltState = true" placeholder="请选择是否停机"
+                        type="select" /> -->
+                    <u-radio-group v-model="form.needStop" @change="radioGroupChange">
+                        <u-radio :name="0">
+                            否
+                        </u-radio>
+                        <u-radio :name="1">
+                            是
+                        </u-radio>
+                    </u-radio-group>
+                </u-form-item>
+                <u-form-item label="报修人" prop="actualUser" required :label-width="150">
+                    <u-input v-model="form.actualUser" :cursor-spacing="cursorSpacing" />
+                </u-form-item>
+                <u-form-item label="故障描述" prop="content" required :label-width="150">
                     <u-input v-model="form.content" :cursor-spacing="cursorSpacing" />
                 </u-form-item>
+                <!--                <u-select v-model="aShow" mode="mutil-column-auto" :list="aList" @confirm="confirm"></u-select>-->
                 <u-form-item label="上传图片" :label-width="150">
                     <u-upload width="180" height="180" max-count="6" :action="action" :file-list="fileList"
-                        @on-success="uploadSuccess" @on-remove="uploadRemove" :header="header"></u-upload>
+                        @on-success="uploadSuccess" @on-remove="uploadRemove"></u-upload>
                 </u-form-item>
             </u-form>
             <view class="d-flex j-around a-center footer">
@@ -126,20 +116,19 @@ export default {
                 badType: '',
                 running: '',
                 sbName: '',
-                actualUser: '',
-                no: '',
-                halt: '',
                 sbCph: '',
+                bianhao: '',
+                halt: '',
                 repair: '',
                 remarks: '',
+                actualUser: '',
                 content: '',
-                userId: '',
                 repairErrorTypeId: '',
                 photo: '',
                 level: '',
                 // 传入的
                 sbId: '',
-                needStop: '',
+                needStop: 0,
                 levelValue: '',
                 source: ''
             },
@@ -227,6 +216,7 @@ export default {
             // #endif
             sbBackId: '',
             address: '',
+            sbPositionData: [],
             tabbar: [
                 {
                     iconPath: '/static/tabars/home.png',
@@ -263,74 +253,103 @@ export default {
         }
     },
     onShow() {
-        console.log(this.action)
+        this.userInfo = this.$BaseTool.UserUtil.getUserInfo()
+        if (this.userInfo) {
+            this.form.actualUser = this.userInfo.realName
+        }
         const pages = getCurrentPages()
         const currPage = pages[pages.length - 1]
         this.sbBackId = currPage.sbBackId
+        this.sbId = currPage.sbBackId
         if (this.sbBackId) {
             this.$Http
-                .fetchSbInfo({
+                .fetchSbInfoIgnores({
                     id: this.sbBackId
                 })
                 .then(res => {
-                    this.form.no = res.data.no
+                    this.form.bianhao = res.data.no
                     this.form.sbName = res.data.name
-                    this.form.running = res.data.name
                     this.form.sbCph = res.data.cph
+                    this.form.running = res.data.name
                     this.form.sbId = this.sbBackId
                 })
         }
     },
     onLoad(options) {
+
         if (options && options.detailId) {
+            this.sbId = options.detailId
             this.$Http
-                .fetchSbInfo({
+                .fetchSbInfoIgnores({
                     id: options.detailId
                 })
                 .then(res => {
-                    this.form.no = res.data.no
+                    this.form.bianhao = res.data.no
                     this.form.sbName = res.data.name
                     this.form.running = res.data.name
-                    this.form.sbCph = res.data.cph
                     this.form.sbId = options.detailId
+                    this.form.sbCph = res.data.cph
                 })
         }
-        this.sourceMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
-        const categoryMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY)
-        for (const key in categoryMap) {
-            this.categoryMap.push({
-                label: categoryMap[key],
-                value: key
-            })
-        }
-        for (const key in this.sourceMap) {
-            this.repairList.push({
-                label: this.sourceMap[key],
-                value: key
+        // this.sourceMap = this.$DictCache.getLabelByValueMapByType(
+        //     this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE
+        // );
+        // for (const key in this.sourceMap) {
+        //     this.repairList.push({
+        //         label: this.sourceMap[key],
+        //         value: key
+        //     });
+        // }
+        // this.form.repair = this.repairList[0].label;
+        // this.form.source = this.repairList[0].value;
+        // this.levelMap = this.$DictCache.getLabelByValueMapByType(
+        //     this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL
+        // );
+        // for (const key in this.levelMap) {
+        //     this.levelList.push({
+        //         label: this.levelMap[key],
+        //         value: key
+        //     });
+        // }
+        // this.form.level = this.levelList[0].label;
+        // this.form.levelValue = this.levelList[0].value;
+
+        // this.statusMap = this.$DictCache.getLabelByValueMapByType(
+        //     this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS
+        // );
+        console.log(22)
+        this.$Http
+            .getDictType({
+                type: this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY
             })
-        }
-        this.form.repair = this.repairList[0].label
-        this.form.source = this.repairList[0].value
-        this.levelMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
-        for (const key in this.levelMap) {
-            this.levelList.push({
-                label: this.levelMap[key],
-                value: key
+            .then(res => {
+                this.categoryMap = res.data
             })
-        }
-        this.form.level = this.levelList[0].label
-        this.form.levelValue = this.levelList[0].value
-
-        this.statusMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
-        this.needStopMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.YES_NO)
-        for (const key in this.needStopMap) {
-            this.haltList.push({
-                label: this.needStopMap[key],
-                value: key
+        this.$Http
+            .getSbPositionTree().then(res => {
+                this.sbPositionData = res.data
             })
-        }
-        this.form.halt = this.haltList[this.haltDefaultValue].label
-        this.form.needStop = this.haltList[this.haltDefaultValue].value
+        // const categoryMap = this.$DictCache.getLabelByValueMapByType(
+        //     this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY
+        // )
+        // for (const key in categoryMap) {
+        //     this.categoryMap.push({
+        //         label: categoryMap[key],
+        //         value: key
+        //     });
+        // }
+        // console.log(this.categoryMap)
+        // this.needStopMap = this.$DictCache.getLabelByValueMapByType(
+        //     this.$DictCache.TYPE.YES_NO
+        // )
+        // for (const key in this.needStopMap) {
+        //     this.haltList.push({
+        //         label: this.needStopMap[key],
+        //         value: key
+        //     });
+        // }
+        // this.form.halt = this.haltList[this.haltDefaultValue].label;
+        // this.form.needStop = this.haltList[this.haltDefaultValue].value;
         this.getType()
         // 获取设备数据
         // this.initSb();
@@ -374,22 +393,24 @@ export default {
                 url: '/pages/search/search'
             })
         },
+        // 是否停机切换
+        radioGroupChange(value) {
+            this.form.needStop = value
+        },
         handleSubmit() {
+            console.log(this.form);
+
             if (this.form.sbId === null || this.form.sbId === '') {
                 this.$Message.toast('请先输入设备新号')
                 return
             }
             const params = {
                 content: this.form.content,
-                remark: this.form.remarks,
-                level: this.form.levelValue,
                 needStop: this.form.needStop,
                 sbId: this.form.sbId,
                 sbName: this.form.sbName,
                 sbCph: this.form.sbCph,
-                repairErrorTypeId: this.form.repairErrorTypeId,
-                source: this.form.source,
-                category: this.form.category,
+                actualUser: this.form.actualUser,
                 applicationFileList: this.imagesList
             }
             console.log(params)
@@ -401,6 +422,7 @@ export default {
             this.$refs.uForm.validate(valid => {
                 if (valid) {
                     this.$Http.addRepairApplicationForm(params).then(res => {
+                        this.resetForm()
                         uni.navigateTo({
                             url: '/pages/repair/repair'
                         })
@@ -408,6 +430,30 @@ export default {
                 }
             })
         },
+        // 报修提交成功后清除表单数据
+        resetForm() {
+            this.form = {
+                badType: '',
+                running: '',
+                sbName: '',
+                sbCph: '',
+                bianhao: '',
+                halt: '',
+                repair: '',
+                remarks: '',
+                actualUser: this.userInfo ? this.userInfo.realName : '',
+                content: '',
+                repairErrorTypeId: '',
+                photo: '',
+                level: '',
+                sbId: '',
+                needStop: 0,
+                levelValue: '',
+                source: ''
+            }
+            this.imagesList = []
+            this.fileList = []
+        },
         // 紧急等级
         levelSubmit(data) {
             this.form.level = data[0].label

+ 60 - 32
pages/repair-add/repair-add.vue

@@ -36,21 +36,7 @@
                         @confirm="repairSubmit"
                     ></u-select>
                 </u-form-item>-->
-                <!--                <u-form-item label="是否停机" required prop="halt" :label-width="150">
-                    <u-input
-                        v-model="form.halt"
-                        disabled
-                        @click="haltState = true"
-                        placeholder="请选择是否停机"
-                        type="select"
-                    />
-                    <u-select
-                        v-model="haltState"
-                        :list="haltList"
-                        @confirm="haltSubmit"
-                        :default-value="haltDefaultValue"
-                    ></u-select>
-                </u-form-item>
+                <!--                
                 <u-form-item label="紧急等级" prop="level" required :label-width="150">
                     <u-input
                         v-model="form.level"
@@ -89,12 +75,24 @@
                     ></u-select>
                 </u-form-item> -->
                 <u-form-item label="使用位置" prop="sbCph" required :label-width="150">
-                    <u-input v-model="form.sbCph" :cursor-spacing="cursorSpacing" />
+                    <tree-select v-model="form.sbCph" valueName="title" :data="sbPositionData"></tree-select>
+                </u-form-item>
+                <u-form-item label="是否停机" required prop="needStop" :label-width="150">
+                    <!-- <u-input v-model="form.halt" disabled @click="haltState = true" placeholder="请选择是否停机"
+                        type="select" /> -->
+                    <u-radio-group v-model="form.needStop" @change="radioGroupChange">
+                        <u-radio :name="0">
+                            否
+                        </u-radio>
+                        <u-radio :name="1">
+                            是
+                        </u-radio>
+                    </u-radio-group>
                 </u-form-item>
                 <u-form-item label="报修人" prop="actualUser" required :label-width="150">
                     <u-input v-model="form.actualUser" :cursor-spacing="cursorSpacing" />
                 </u-form-item>
-                <u-form-item label="故障描述" :label-width="150">
+                <u-form-item label="故障描述" prop="content" required :label-width="150">
                     <u-input v-model="form.content" :cursor-spacing="cursorSpacing" />
                 </u-form-item>
                 <!--                <u-select v-model="aShow" mode="mutil-column-auto" :list="aList" @confirm="confirm"></u-select>-->
@@ -132,7 +130,7 @@ export default {
                 level: '',
                 // 传入的
                 sbId: '',
-                needStop: '',
+                needStop: 0,
                 levelValue: '',
                 source: ''
             },
@@ -229,12 +227,16 @@ export default {
             sbBackId: '',
             aShow: false,
             address: '',
+            sbPositionData: [],
             sbId: null,
             aList: []
         }
     },
     onShow() {
-        console.log(this.action)
+        this.userInfo = this.$BaseTool.UserUtil.getUserInfo()
+        if (this.userInfo) {
+            this.form.actualUser = this.userInfo.realName
+        }
         const pages = getCurrentPages()
         const currPage = pages[pages.length - 1]
         this.sbBackId = currPage.sbBackId
@@ -254,10 +256,7 @@ export default {
         }
     },
     onLoad(options) {
-        this.userInfo = this.$BaseTool.UserUtil.getUserInfo()
-        if (this.userInfo) {
-            this.form.actualUser = this.userInfo.realName
-        }
+
         if (options && options.detailId) {
             this.sbId = options.detailId
             this.$Http
@@ -306,6 +305,10 @@ export default {
             .then(res => {
                 this.categoryMap = res.data
             })
+        this.$Http
+            .getSbPositionTree().then(res => {
+                this.sbPositionData = res.data
+            })
         // const categoryMap = this.$DictCache.getLabelByValueMapByType(
         //     this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY
         // )
@@ -315,10 +318,10 @@ export default {
         //         value: key
         //     });
         // }
-        console.log(this.categoryMap)
+        // console.log(this.categoryMap)
         // this.needStopMap = this.$DictCache.getLabelByValueMapByType(
         //     this.$DictCache.TYPE.YES_NO
-        // );
+        // )
         // for (const key in this.needStopMap) {
         //     this.haltList.push({
         //         label: this.needStopMap[key],
@@ -370,26 +373,27 @@ export default {
                 url: '/pages/search/search'
             })
         },
+        // 是否停机切换
+        radioGroupChange(value) {
+            this.form.needStop = value
+        },
         handleSubmit() {
             const params = {
                 content: this.form.content,
-                remark: this.form.remarks,
                 actualUser: this.form.actualUser,
-                level: this.form.levelValue,
                 needStop: this.form.needStop,
                 sbId: this.form.sbId,
                 sbName: this.form.sbName,
                 sbCph: this.form.sbCph,
-                repairErrorTypeId: this.form.repairErrorTypeId,
-                source: this.form.source,
-                category: this.form.category,
                 applicationFileList: this.imagesList
             }
             // this.form.photo = a.join(',');
             var that = this
             this.$refs.uForm.validate(valid => {
                 if (valid) {
-                    this.$Http.addRepairApplicationFormIgnores(params).then(res => {
+                    this.$Http.addRepairApplicationForm(params).then(res => {
+                        const sbId = that.form.sbId
+                        that.resetForm()
                         uni.showToast({
                             icon: 'none',
                             title: '报修单已提交!',
@@ -397,13 +401,37 @@ export default {
                         })
                         setTimeout(function () {
                             uni.navigateTo({
-                                url: '/pages/equipment-detail/equipment-detail?detailId=' + that.form.sbId
+                                url: '/pages/equipment-detail/equipment-detail?detailId=' + sbId
                             })
                         }, 2000)
                     })
                 }
             })
         },
+        // 报修提交成功后清除表单数据
+        resetForm() {
+            this.form = {
+                badType: '',
+                running: '',
+                sbName: '',
+                sbCph: '',
+                bianhao: '',
+                halt: '',
+                repair: '',
+                remarks: '',
+                actualUser: this.userInfo ? this.userInfo.realName : '',
+                content: '',
+                repairErrorTypeId: '',
+                photo: '',
+                level: '',
+                sbId: '',
+                needStop: 0,
+                levelValue: '',
+                source: ''
+            }
+            this.imagesList = []
+            this.fileList = []
+        },
         // 紧急等级
         levelSubmit(data) {
             this.form.level = data[0].label

+ 5 - 4
pages/search/search.vue

@@ -6,8 +6,9 @@
         </view>
         <view style="padding-top: 104rpx;">
             <template v-if="listData.length > 0">
-                <view class="py2 px3 one-ellipsis border-bottom" v-for="(item,index) in listData" :key="index" @click="handleBack(item)">
-                    {{ item.name + '  (' + (item.zbh==null?item.no:item.zbh) + ')' }}
+                <view class="py2 px3 one-ellipsis border-bottom" v-for="(item, index) in listData" :key="index"
+                    @click="handleBack(item)">
+                    {{ item.no }}——{{ item.name }}——{{ item.zbh }}
                 </view>
                 <view class="py3">
                     <u-loadmore :status="status" />
@@ -99,7 +100,7 @@ export default {
 </script>
 
 <style scoped>
-page{
-	background-color: #FFFFFF;
+page {
+    background-color: #FFFFFF;
 }
 </style>

Деякі файли не було показано, через те що забагато файлів було змінено