123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665 |
- <template>
- <view>
- <!-- 状态 -->
- <!-- && userInfoRoleName.indexOf('admin') == -1 -->
- <view class="label" v-if="(form.status == 2 || form.status == 3 || form.status == 4)">
- <view class="tab" ref="wx" :style="{'color':wxStyle,'height':'100%','border-right': '1rpx solid #f4f4f4'}" @click="tab('wx')">
- <text>报修单</text>
- </view>
- <view class="tab" ref="gz" :style="{'color':gzStyle,'height':'100%','border-left': '1rpx solid #f4f4f4'}" @click="tab('gz')">
- <text>工作单</text>
- </view>
- </view>
-
- <view class="repairdetails" v-if="form.status == 1">
-
- <view class="cardBox">
- <!-- <view class="text">设备信息:</view> -->
- <u-input v-model="form.deviceName" disabledColor="#fff" disabled
- border="none" placeholder="请选择设备信息" >
- <template slot="suffix">
- <u-icon name="scan" color="#bbb" size="32"></u-icon>
- </template>
- </u-input>
- </view>
-
- <view class="cardBox">
- <!-- <view class="text">客户名称:</view> -->
- <u-input v-model="form.corpName" disabled disabledColor="#fff"
- border="none" placeholder="客户名称" ></u-input>
- </view>
-
- <view class="cardBox">
- <!-- <view class="text">地址:</view> -->
- <u-input v-model="form.deviceAddress" disabledColor="#fff" disabled
- border="none" placeholder="设备地址" ></u-input>
- </view>
-
- <view class="cardBox">
- <!-- <view class="text">故障描述:</view> -->
- <u--textarea v-model="form.faultDescribe" placeholder="故障描述" disabled
- border="none" >
- </u--textarea>
- </view>
-
-
- <view class="kapian">
- <!-- <view style="font-size: 30rpx;color: #999;margin-left: 10rpx;">添加图片</view> -->
- <view style="margin-top: 20rpx;">
- <u-upload
- :fileList="form.maintenanceFiles"
- :disabled="form.status != 3"
- @afterRead="afterRead"
- @delete="deletePic"
- name="1"
- multiple
- :maxCount="10"
- ></u-upload>
- </view>
- </view>
-
- </view>
-
-
-
- <view class="repairdetails" v-if="wxStyle != ''">
-
- <view class="cardBox">
- <!-- <view class="text">设备信息:</view> -->
- <u-input v-model="form.deviceName" disabledColor="#fff" disabled
- border="none" placeholder="请选择设备信息" >
- <template slot="suffix">
- <u-icon name="scan" color="#bbb" size="32"></u-icon>
- </template>
- </u-input>
- </view>
-
- <view class="cardBox">
- <!-- <view class="text">客户名称:</view> -->
- <u-input v-model="form.corpName" disabled disabledColor="#fff"
- border="none" placeholder="客户名称" ></u-input>
- </view>
-
- <view class="cardBox">
- <!-- <view class="text">地址:</view> -->
- <u-input v-model="form.deviceAddress" disabledColor="#fff" disabled
- border="none" placeholder="设备地址" ></u-input>
- </view>
-
- <view class="cardBox">
- <!-- <view class="text">故障描述:</view> -->
- <u--textarea v-model="form.faultDescribe" placeholder="故障描述" disabled
- border="none" >
- </u--textarea>
- </view>
-
-
- <view class="kapian">
- <!-- <view style="font-size: 30rpx;color: #999;margin-left: 10rpx;">添加图片</view> -->
- <view style="margin-top: 20rpx;">
- <u-upload
- :fileList="form.maintenanceFiles"
- :disabled="form.status != 3"
- @afterRead="afterRead"
- @delete="deletePic"
- name="1"
- multiple
- :maxCount="10"
- ></u-upload>
- </view>
- </view>
-
- </view>
-
-
- <view class="repairdetails" v-if="gzStyle != ''">
-
- <view class="cardBox">
- <!-- <view class="text">设备信息:</view> -->
- <u-input v-model="form.deviceName" disabledColor="#fff" disabled
- border="none" placeholder="请选择设备信息" >
- <template slot="suffix">
- <u-icon name="scan" color="#bbb" size="32"></u-icon>
- </template>
- </u-input>
- </view>
-
- <view class="cardBox">
- <u--textarea v-model="form.repairDescription" placeholder="维修描述" border="none" :disabled="form.status != 3" >
- </u--textarea>
- </view>
-
- <view class="kapian">
- <!-- <view style="font-size: 30rpx;color: #999;margin-left: 10rpx;">添加图片</view> -->
- <view style="margin-top: 20rpx;">
- <u-upload
- :fileList="form.maintenanceFiles"
- :disabled="form.status != 3"
- @afterRead="afterRead"
- @delete="deletePic"
- name="1"
- multiple
- :maxCount="10"
- ></u-upload>
- </view>
- </view>
-
- <view >
- <view class="kapian" v-for="(item,index) in form.maintenanceFees" :key="item.id">
- <view class="WXflex">
- <view class="wxscfun" v-if="form.status == 3" @click="maintenanceDe(item,index)">删除</view>
- </view>
- <view class="repairProject">
- <view class="wxbox">
- <u-input v-model="item.costName" disabledColor="#fff" :disabled="form.status != 3"
- border="none" placeholder="添加项目" ></u-input>
- </view>
-
- <view class="wxbox">
- <u-input v-model="item.amount" disabledColor="#fff" :disabled="form.status != 3"
- border="none" inputAlign="right" @input="moneyInput" placeholder="金额" >
- <u--text
- text="元"
- slot="suffix"
- margin="0 3px 0 0"
- type="tips"
- ></u--text>
- </u-input>
- </view>
- </view>
- </view>
- </view>
-
-
- <view class="kapian" >
- <view class="wxtitleflex">
- <view class="wxtitle">添加费用</view>
- <view v-if="form.status == 3 && type != 'XQ'" class="addwx" @click="wxaddfun">添加</view>
- </view>
- </view>
- </view>
-
-
-
-
-
-
- <u-gap height="60"></u-gap>
-
- <view class="bottombox" v-if="type != 'XQ'">
- <view class="bottombox_name" v-if="form.status != 3 && form.status != 1">
- <text>{{form.maintenanceWorkerName}}</text>
- </view>
- <view class="bottombox_name" @click="pickerShowfun" v-if="form.status == 1 && userInfoRoleName.indexOf('admin') != -1">
- <text>{{form.maintenanceWorkerName == null || form.maintenanceWorkerName == '' ? '请选择维修工' : form.maintenanceWorkerName}}</text>
- </view>
- <view v-if="form.status == 3" style="color: #FD4B09;">维修费:{{form.maintenanceAmount}}元</view>
- <view class="bottombox_right">
- <view class="buttonClass"
- v-if="form.status == 1 && userInfoRoleName.indexOf('admin') != -1"
- @click="maintenanceDispatchingWorkersfun">确认派工</view>
- <view class="buttonClass"
- v-if="form.status == 2 && userInfoRoleName.indexOf('admin') != -1"
- @click="maintenanceRevokeDispatchingWorkersfun">撤销派工</view>
- <view class="buttonClass" v-if="form.status == 2 && userInfoRoleName.indexOf('维修工') != -1" @click="receivingOrdersfun">确认接单</view>
- <view class="buttonClass" v-if="form.status == 3" @click="Confirmexpenses">确认费用</view>
- <view class="buttonClass" v-if="form.status == 4" @click="Confirmexpenses">确认结算</view>
- </view>
- </view>
-
- <u-picker :show="pickerShow" :columns="pickerList" keyName="name"
- @confirm="pickerShowConfirm" @cancel="pickerShowCancel"></u-picker>
-
- <u-toast ref="uToast"></u-toast>
- </view>
- </template>
- <script>
- import {
- maintenanceDetail,
- maintenanceReceivingOrders,
- maintenanceConfirm,
- userList,
- maintenanceDispatchingWorkers,
- maintenanceRevokeDispatchingWorkers
- } from '@/api/device/index.js'
- import http from '@/http/api.js'
- import {
- clientId,
- clientSecret
- } from '@/common/setting'
- export default {
- data() {
- return {
- id:null,
- wxStyle: '',
- gzStyle: '',
- range: [
- { value: 0, text: "篮球" },
- { value: 1, text: "足球" },
- { value: 2, text: "游泳" },
- ],
- form:{
- maintenanceFees:[
- {
- id:null,
- costId:null,
- costName:null,
- number:1,
- price:null,
- amount:null,
- currency:'CNY',
- settlementAmount:null,
- remarks:null,
- }
- ]
- },
- // 弹窗的开启
- pickerShow:false,
- pickerList:[],
- userInfoRoleName:[]
- }
- },
- onLoad(e) {
- this.id = e.id
- this.type = e.type
- this.userInfoRoleName = uni.getStorageSync('userInfo').role_name.split(',')
- this.maintenanceDetailfun()
- },
- onShow() {
-
- },
- methods: {
- moneyInput() {
- var money = 0
-
- for (let fees of this.form.maintenanceFees) {
- money += Number(fees.amount)
- }
-
- this.form.maintenanceAmount = money;
- },
- tab(type) {
- if(type == "wx") {
- this.wxStyle = "#fd4b09"
- this.gzStyle = ""
- // this.form.status = 2
-
- } else if (type == "gz") {
- this.gzStyle = "#fd4b09"
- this.wxStyle = ""
- // this.form.status = 3
- }
- },
- // 设备删除
- maintenanceDe(row,index){
- this.form.maintenanceFees.splice(index,1)
- this.moneyInput()
- },
- // 撤销派工
- maintenanceRevokeDispatchingWorkersfun(){
- maintenanceRevokeDispatchingWorkers(this.form).then(res=>{
- if (res.code == 200) {
- this.$refs.uToast.show({
- type: 'success',
- message: "撤销派工成功",
- })
- this.form = res.data
- }else {
- this.$refs.uToast.show({
- type: 'error',
- message: res.msg,
- })
- }
- })
- },
- // 派工
- maintenanceDispatchingWorkersfun(){
- if (!this.form.maintenanceWorkerId) {
- return this.$refs.uToast.show({type: 'warning',message: '请选择维修工'})
- }
- // if (!this.form.maintenanceWorkerTel) {
- // return this.$refs.uToast.show({type: 'warning',message: '请输入维修工电话'})
- // }
- maintenanceDispatchingWorkers(this.form).then(res=>{
- if (res.code == 200) {
- this.$refs.uToast.show({
- type: 'success',
- message: "派工成功",
- })
- this.form = res.data
- }else {
- this.$refs.uToast.show({
- type: 'error',
- message: res.msg,
- })
- }
-
- })
- },
- // 维修工弹窗开启
- pickerShowfun(){
- this.pickerShow = true
- this.userListfun()
- },
- // 维修工获取
- userListfun(){
- userList({roleAlias:'维修工'}).then(res=>{
- this.pickerList = [res.data]
- })
- },
- // 维修工弹窗的确认
- pickerShowConfirm(e){
- console.log(e.value[0],181);
- this.form.maintenanceWorkerId = e.value[0].id
- this.form.maintenanceWorkerName = e.value[0].name
- this.form.maintenanceWorkerTel = e.value[0].phone
- this.pickerShow = false
-
- },
- // 维修工弹窗取消
- pickerShowCancel() {
- this.pickerShow = false
- },
- // 维修费用的添加
- wxaddfun(){
- this.form.maintenanceFees.push({
- id:null,
- costId:null,
- costName:null,
- number:1,
- price:null,
- amount:null,
- currency:'CNY',
- settlementAmount:null,
- remarks:null,
- })
- },
- // 确认费用
- Confirmexpenses(){
- let a = true
- if (this.form.maintenanceFees.length <= 0) {
- return this.$refs.uToast.show({type: 'warning',message: '请添加维修费用'})
- }else {
- this.form.maintenanceFees.map((item,index)=>{
- if (!item.costName) {
- this.$refs.uToast.show({type: 'warning',message: `请填写序号${index + 1}的费用名称`})
- a = false
- return
- }
- if (!item.amount) {
- this.$refs.uToast.show({type: 'warning',message: `请填写序号${index + 1}的金额`})
- a = false
- return
- }
- })
- if (a == false) return
-
- maintenanceConfirm(this.form).then(res=>{
- if (res.code == 200) {
- this.$refs.uToast.show({
- type: 'success',
- message: "接单成功",
- })
- // uni.navigateBack({
- // delta: 1
- // });
- this.form = res.data
- }else {
- this.$refs.uToast.show({
- type: 'error',
- message: res.msg,
- })
- }
- })
-
- }
-
- },
- // 确认接单接口
- receivingOrdersfun(){
- maintenanceReceivingOrders(this.form).then(res=>{
- console.log(res,180);
- if (res.code == 200) {
- this.$refs.uToast.show({
- type: 'success',
- message: "接单成功",
- })
- this.form = res.data
- }else {
- this.$refs.uToast.show({
- type: 'error',
- message: res.msg,
- })
- }
- })
- },
- // 维修设备详情
- maintenanceDetailfun(){
- maintenanceDetail({id:this.id}).then(res=>{
- this.form = res.data
-
-
-
- if (this.form.status == 4) {
- this.gzStyle = "#fd4b09"
- this.wxStyle = ""
- } else if (this.form.status == 3) {
- this.gzStyle = "#fd4b09"
- this.wxStyle = ""
- } else if (this.form.status == 2) {
- console.log(this.form.status);
- this.wxStyle = "#fd4b09"
- this.gzStyle = ""
- } else if (this.form.status == 1) {
- userList({roleAlias:'维修工'}).then(res=>{
- this.wxUserList = [res.data]
- })
- }
- // if (this.type == 'JD') {
- // this.form.maintenanceFees.push({
- // id:null,
- // costId:null,
- // costName:null,
- // number:1,
- // price:null,
- // amount:null,
- // currency:'CNY',
- // settlementAmount:null,
- // remarks:null,
- // })
- // }
- })
- },
-
- // 图片删除
- deletePic(e){
- if(e.file.uploadType == 0) return this.$refs.uToast.show({ type: 'warning', message: '请勿删除客户添加的图片',})
- this.form.maintenanceFiles.splice(e.index,1)
- },
- // 上传图片
- async afterRead(event){
- // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
- let lists = [].concat(event.file)
- console.log(lists);
- let fileListLen = this.form.maintenanceFiles.length
- lists.map((item) => {
- this.form.maintenanceFiles.push({
- uploadType:1,
- ...item
- })
- })
- for (let i = 0; i < lists.length; i++) {
- const result = await this.uploadFilePromise(lists[i].url)
- let item = this.form.maintenanceFiles[fileListLen]
- this.form.maintenanceFiles.splice(fileListLen, 1, Object.assign(item, {
- sort: this.form.maintenanceFiles.length,
- fileName: JSON.parse(result).data.originalName,
- url: JSON.parse(result).data.link
- }))
- fileListLen++
- }
- },
- uploadFilePromise(url) {
- return new Promise((resolve, reject) => {
- let a = uni.uploadFile({
- url: http.config.baseURL +
- '/blade-resource/oss/endpoint/put-file', // 仅为示例,非真实的接口地址
- filePath: url,
- name: 'file',
- formData: {
- user: 'test'
- },
- header: {
- // 客户端认证参数
- 'Authorization': 'Basic ' + Base64.encode(clientId + ':' +
- clientSecret),
- 'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken')
- },
- success: (res) => {
- setTimeout(() => {
- resolve(res.data)
- }, 1000)
- }
- });
- })
- },
-
- }
- }
- </script>
- <style lang="scss" scoped>
-
- .label {
- left: 0rpx;
- top: 190rpx;
- width: 100%;
- height: 114rpx;
- line-height: 40rpx;
- background-color: rgba(255, 255, 255, 1);
- text-align: center;
-
- display: flex;
-
- align-items: center;
-
- .tab {
- width: 50%;
- display: flex;
- color: #c4c4c4;
-
- align-items: center;
- justify-content: center;
- font-size: 40rpx;
- text-align: left;
- font-family: PingFangSC-semiBold;
-
- }
- }
-
- .repairdetails {
- padding: 20rpx;
- box-sizing: border-box;
- }
- .cardBox {
- background: #fff;
- border-radius: 12rpx;
- width: 100%;
- padding: 30rpx;
- box-sizing: border-box;
- margin-bottom: 20rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .text {
- font-size: 30rpx;
- color: #999;
- margin-right: 10rpx;
- }
- .kapian {
- background: #fff;
- border-radius: 12rpx;
- width: 100%;
- padding: 30rpx;
- box-sizing: border-box;
- margin-bottom: 20rpx;
-
- .repairProject {
- display: flex;
- }
-
- .wxtitleflex {
- display: flex;
- align-items: center;
- justify-content: space-between;
- }
- .wxtitle {
- font-size: 34rpx;
- color: #888;
- }
- .wxbox {
- border-bottom: 2rpx solid #eee;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 20rpx 0;
- margin: 10rpx 0;
- }
- .addwx {
- color: #dd451b;
- font-size: 30rpx;
- padding: 10rpx 20rpx;
- border: 2rpx solid;
- border-radius: 30rpx;
- }
- .WXflex {
- display: flex;
- justify-content: space-between;
- align-items: center;
- .xuhao {
- font-size: 32rpx;
- color: #101010;
- }
- .wxscfun {
- color: red;
- font-size: 30rpx;
- padding: 10rpx 20rpx;
- border: 2rpx solid;
- border-radius: 28rpx;
- }
- }
- }
- .bottombox {
- position: fixed;
- bottom: 0;
- width: 100%;
- height: 120rpx;
- background: #fff;
- box-shadow: 0rpx 4rpx 4rpx 4rpx rgba(0, 0, 0, 0.5);
- padding: 0 40rpx;
- box-sizing: border-box;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .bottombox_name {
- font-size: 38rpx;
- color: #101010;
- }
- .bottombox_right {
- display: flex;
- .buttonClass {
- // background: #2d4a6a;
- background: #FD4B09;
- padding: 10rpx 60rpx;
- border-radius: 30rpx;
- color: #fff;
- // font-weight: bold;
- // margin: 0 10rpx;
- }
- }
- }
- </style>
|