123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421 |
- <template>
- <view class="jpmain ">
- <u-navbar title="故障上报" title-color="#101010"></u-navbar>
- <view class="list">
- <view class="item">
- <view class="name">
- <span>*</span>选择场站
- </view>
- <view class="value" @click="gotoSelectStation()">
- <view :style="taskInfo.stationId?'':'color:#BBB'">{{taskInfo.stationId?stationName:'选择故障上报的场站'}}</view>
- <u-icon name="arrow-right" size="24" color="#BBBBBB"></u-icon>
- </view>
- </view>
- <view class="item">
- <view class="name">
- <span>*</span>故障类型
- </view>
- <view class="value" @click="selectTaskInfoCodeBtn">
- <view :style="taskInfo.code?'':'color:#BBB'">{{taskInfo.code?codeN:'请选择故障类型'}}</view>
- <u-icon name="arrow-right" size="24" color="#BBBBBB"></u-icon>
- </view>
- </view>
- <view class="item item-plus">
- <view class="name">
- <span>*</span>上报人员
- </view>
- <view class="value ">
- <u-checkbox-group>
- <u-checkbox v-model="item.checked" @change="memberListchange"
- v-for="(item, index) in memberList" :key="index"
- :name="item.name">{{item.name}}</u-checkbox>
- </u-checkbox-group>
- </view>
- </view>
- </view>
- <view class="list">
- <view class="item item-plus">
- <view class="name">
- <span>*</span>故障描述
- </view>
- <view class="value">
- <textarea placeholder="请简单描述故障问题" v-model="taskInfo.desc" placeholder-class="textareaclass"
- class="textarea"></textarea>
- </view>
- </view>
- <view class="item item-plus">
- <view class="name">
- <span>*</span>拍照上传
- </view>
- <view class="value">
- <u-upload name="photoFile" ref="uUpload" :form-data="formData" :header="header" :action="action"
- :file-list="listPic"></u-upload>
- </view>
- </view>
- </view>
- <u-select v-model="selectTaskInfoCode" :default-value="selectTaskInfoCodeValue" value-name="value"
- label-name="name" @confirm="selectTaskInfoCodeConfirm" :list="codeList"></u-select>
- <view class="floating-button">
- <view class="button" @click="submit">
- 提交
- </view>
- </view>
- </view>
- </template>
- <script>
- import * as API from '@/apis/pagejs/pagesTask.js'
- export default {
- data() {
- return {
- listPic: [],
- memberList: [],
- action: "",
- formData: {
- },
- header: {
- },
- codeN: "",
- selectTaskInfoCode: false,
- selectTaskInfoCodeValue: [0],
-
- stationName: "",
- taskInfo: {
- stationId: "",
- code: "",
- desc: "",
- images: "",
- },
- codeList: []
- };
- },
- onLoad() {
- this.action = process.jphelp.BASE_URL + "uploadPicture"
- this.formData.subFolder = "/yooudian/inspection/addTask"
- var token = this.jphelp.getToken()
- this.header = {
- 'Authorization': token
- }
- this.getteamMembers()
- this.findByCatalogName({
- catalogName: '设备故障类型'
- }, "codeList")
- },
- methods: {
- memberListchange(e){
- console.log(e)
- this.$forceUpdate()
- },
- submit() {
-
-
-
- if (!this.taskInfo.stationId) {
- uni.showToast({
- title: "选择故障上报的场站"
- })
- return
- }
- if (!this.taskInfo.code) {
- uni.showToast({
- title: "请选择故障类型"
- })
- return
- }
-
- var mp=this.memberList.filter(item=>{
- return item.checked
- }).map(item=>{
- return item.id
- })
-
- if (mp.length==0) {
- uni.showToast({
- title: "请选择上报人员"
- })
- return
- }
-
- if (!this.taskInfo.desc) {
- uni.showToast({
- title: "请简单描述故障问题"
- })
- return
- }
-
-
- let files = [];
- // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作)
- files = this.$refs.uUpload.lists.filter(val => {
- return val.progress == 100;
- })
- // 如果您不需要进行太多的处理,直接如下即可
- // files = this.$refs.uUpload.lists;
- //(files);
- var imgUrl = files.map(item => {
- return item.response.data;
- })
- if (imgUrl.length==0) {
- uni.showToast({
- title: "请拍照上传现场照片"
- })
- return
- }
- //(imgUrl);
- this.taskInfo.images = imgUrl.join(',');
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- API.addErr(this.taskInfo).then((res) => {
- uni.showModal({
- title: '提示',
- showCancel: false,
- content: "上报成功",
- success: res1 => {
- if (res1.confirm) {
- uni.navigateBack()
- } else if (res1.cancel) {
- //('用户点击取消');
- }
- }
- })
- uni.hideLoading();
- }).catch(error => {
- uni.hideLoading();
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- findByCatalogName(obj, listName) {
- API.findByCatalogName(obj).then((res) => {
- var arr = res.data.dataDictionaryList
- this[listName] = arr
- }).catch(error => {
- uni.hideLoading();
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- getteamMembers() {
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- API.teamMembers().then((res) => {
- var arr = res.data.memberList
- this.memberList = arr
- this.memberList.forEach(item => {
- if (item.id == this.jphelp.getPersonInfo().id) {
- item.checked = true
- } else {
- item.checked = false
- }
- })
- uni.hideLoading();
- }).catch(error => {
- uni.hideLoading();
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- selectTaskInfoCodeConfirm(e) {
- console.log(e)
- this.codeN = e[0].label
- this.taskInfo.code = e[0].value
- },
- selectTaskInfoCodeBtn() {
- if (this.taskInfo.code) {
- //this.selectTaskInfoCodeValue=[parseInt(this.bindInfo.type)-1]
- var i = this.codeList.findIndex(item => {
- return item.value == this.taskInfo.code
- })
- this.selectTaskInfoCodeValue = [i]
- }
- this.selectTaskInfoCode = true;
- },
- gotoSelectStation() {
- uni.navigateTo({
- url: '/pages/task/selectStation',
- events: {
- // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
- acceptDataFromOpenerPage: (item) => {
- console.log(item)
- this.taskInfo.stationId = item.item.id
- this.stationName = item.item.stationName
-
- this.$forceUpdate()
- },
- }
- })
- }
- }
- }
- </script>
- <style lang="scss">
- .jpmain {
- padding-bottom: 120rpx;
- }
- .list {
- background-color: rgba(255, 255, 255, 1);
- border-radius: 8px;
- margin: 20rpx;
- .item:not(:last-child) {
- border-bottom: 2rpx solid rgba(232, 232, 232, 1);
- }
- .item {
- padding: 24rpx;
- display: flex;
- justify-content: space-between;
- .name {
- width: 40%;
- font-size: 32rpx;
- color: #777777;
- span {
- color: red
- }
- white-space: pre;
- }
- .value {
- font-size: 32rpx;
- width: 60%;
- display: flex;
- justify-content: space-between;
- input::placeholder {
- color: #AAAAAA;
- }
- .img {
- width: 40rpx;
- height: 40rpx;
- }
- .textarea {
- background-color: rgba(241, 242, 245, 1);
- width: 100%;
- border-radius: 8rpx;
- }
- }
- }
- .item-plus {
- flex-direction: column;
- .value,
- .name {
- width: 100%;
- }
- .name {
- padding-bottom: 32rpx;
- }
- }
- }
- .floating-button {
- z-index: 999;
- position: fixed;
- bottom: 0;
- /* 距离底部 20px */
- width: 100%;
- display: flex;
- height: 120rpx;
- justify-content: center;
- background-color: rgba(255, 255, 255, 1);
- .button {
- margin-top: 24rpx;
- border-radius: 50px;
- height: 80rpx;
- width: 80%;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 12rpx;
- background-color: rgba(22, 119, 255, 1);
- color: rgba(255, 255, 255, 1);
- font-size: 36rpx;
- }
- }
- .textareaclass {
- padding: 16rpx
- }
- </style>
|