123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- const api = require("../../api/api");
- import Dialog from 'tdesign-miniprogram/dialog/index';
- // pages/workOrderDetail/index.js
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- workLeaderDialog: false,
- showTeams: false,
- teams: []
- },
- async mainData() {
- const res = await api._post({
- "id": "20230208140103",
- "content": {
- nocache: true,
- "sa_workorderid": this.data.id
- }
- })
- console.log("详情", res)
- if (this.data.billData) {
- let userid = wx.getStorageSync('userMsg').userid;
- let item = this.data.billData;
- if (!item.team.some(v => v.userid == userid) && res.data.team.some(v => v.userid == userid)) wx.redirectTo({
- url: '/Eservice/workOrderDetail/index' + '?id=' + item.sa_workorderid,
- })
- }
- this.setData({
- billData: res.data
- })
- this.workerData()
- },
- changeBillStatus(e) {
- const {
- id,
- name
- } = e.target.dataset;
- if (!name) return;
- const dialogConfig = {
- context: this,
- title: '提示',
- content: `是否确定${name}当前工单?`,
- confirmBtn: name,
- cancelBtn: '取消',
- }
- Dialog.confirm(dialogConfig)
- .then(async () => {
- const res = await api._post({
- "id": id,
- "content": {
- "sa_workorderid": this.data.id
- }
- })
- wx.showToast({
- title: res.msg == '成功' ? `工单${name}成功` : res.msg,
- icon: "none",
- mask: true
- });
- if (name == '作废') {
- setTimeout(() => {
- wx.navigateBack()
- }, 500);
- } else {
- this.mainData()
- }
- })
- .catch(() => console.log('点击了取消'))
- .finally(() => Dialog.close())
- },
- async addConfirmBill() {
- const res = await api._post({
- "id": "20230211105703",
- "version": 1,
- "content": {
- "sa_workorder_confirmationid": 0,
- "sa_workorderid": this.data.id,
- "attitudescore": 0,
- "responsescore": 0,
- }
- })
- if (this.data.billData.type === '安装培训') {
- wx.navigateTo({
- url: '/Eservice/trainConfirmBill/index?id=' + res.data.sa_workorder_confirmationid,
- })
- } else if (this.data.billData.type === '安装调试') {
- wx.navigateTo({
- url: '/Eservice/installConfirmBill/index?id=' + res.data.sa_workorder_confirmationid,
- })
- } else {}
- },
- toConfirmBill(data) {
- if (this.data.billData.type === '安装培训') {
- wx.navigateTo({
- url: '/Eservice/trainConfirmBill/index?class=stopClick&id=' + data.currentTarget.dataset.item.sa_workorder_confirmationid,
- })
- }
- },
- async confirmBillList() {
- const res = await api._post({
- "id": "20230211105903",
- "content": {
- "where": {
- nocahce: true,
- "condition": "",
- "sa_workorderid": this.data.id
- }
- }
- })
- this.setData({
- confirmBills: res.data
- })
- },
- toWorkConfirmInfo() {
- getApp().globalData.handelSelect = this
- wx.navigateTo({
- url: '/Eservice/workBillConfirmInfo/index?class=stopClick'
- })
- },
- async workerData() {
- const res = await api._post({
- "id": "20230213143003",
- "version": 1,
- "content": {
- "where": {
- "condition": ""
- }
- }
- })
- this.setData({
- workers: res.data
- })
- },
- /**
- * 开始添加成员或者取消添加
- */
- showTeamDialog() {
- this.setData({
- showTeams: !this.data.showTeams,
- teams: this.data.billData.team.map(v => {
- return v.isleader == 1 ? 0 : v.userid
- })
- })
- },
- /**
- * 选择添加成员
- */
- selectTeams(e) {
- const {
- userid
- } = e.currentTarget.dataset.item;
- let teams = this.data.teams;
- let i = teams.findIndex(v => v == userid);
- if (i != -1) {
- teams = teams.filter(v => v != userid)
- } else {
- teams.push(userid)
- }
- this.setData({
- teams
- })
- },
- addUser() {
- api._post({
- "id": 20220930103603,
- "content": {
- ownertable: 'sa_workorder',
- ownerid: this.data.billData.sa_workorderid,
- "userids": this.data.teams,
- "justuserids": 1
- }
- }).then(res => {
- console.log("添加成员", res)
- wx.showToast({
- title: res.msg == '成功' ? '修改成功' : res.msg,
- icon: "none",
- mask: true
- });
- if (res.msg == '成功') {
- this.mainData()
- this.showTeamDialog()
- }
- })
- },
- showWorkerDialog() {
- this.setData({
- workLeaderDialog: !this.data.workLeaderDialog
- })
- },
- selectLeader(data) {
- this.setData({
- actLeader: data.currentTarget.dataset.item
- })
- },
- async toWorker() {
- if (!this.data.actLeader) {
- wx.showToast({
- title: '未选择负责人',
- icon: 'none'
- })
- } else {
- /* this.data.billData.projectlearders = [this.data.actLeader.userid]
- const res = await api._post({
- "id": "20230208140003",
- "content": this.data.billData
- }) */
- const res = await api._post({
- "id": "20220930103703",
- "content": {
- ownertable: 'sa_workorder',
- ownerid: this.data.billData.sa_workorderid,
- "userid": this.data.actLeader.userid
- }
- })
- this.setData({
- workLeaderDialog: false
- })
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- this.mainData()
- // this.confirmBillList()
- }
- },
- onLoad(options) {
- this.setData({
- id: options.id
- })
- },
- onShow() {
- this.mainData()
- this.confirmBillList()
- },
- })
|