|
@@ -1,111 +1,109 @@
|
|
|
-// pages/nodeDetail/index.js
|
|
|
-import api from '../api/api'
|
|
|
+import api from '../api/api';
|
|
|
+const _Http = getApp().globalData.http
|
|
|
Page({
|
|
|
-
|
|
|
- /**
|
|
|
- * 页面的初始数据
|
|
|
- */
|
|
|
data: {
|
|
|
- stopClick:'',
|
|
|
- SignName:true,
|
|
|
- timerid:null,
|
|
|
- act_confirm_value:'是',
|
|
|
- form:{
|
|
|
- "sa_workorderid":0,
|
|
|
- "sa_workorder_nodeid":0,
|
|
|
- "remarks":"",
|
|
|
- "textcontent":"",
|
|
|
- "confirm_value":"",
|
|
|
- "amount":0,
|
|
|
- "isconfirm":0,
|
|
|
- "team":[],
|
|
|
- "trainers":[
|
|
|
- ],
|
|
|
- "traintitem":[],
|
|
|
+ stopClick: '',
|
|
|
+ SignName: true,
|
|
|
+ timerid: null,
|
|
|
+ act_confirm_value: '是',
|
|
|
+ form: {
|
|
|
+ "sa_workorderid": 0,
|
|
|
+ "sa_workorder_nodeid": 0,
|
|
|
+ "remarks": "",
|
|
|
+ "textcontent": "",
|
|
|
+ "confirm_value": "",
|
|
|
+ "amount": 0,
|
|
|
+ "isconfirm": 0,
|
|
|
+ "team": [],
|
|
|
+ "trainers": [],
|
|
|
+ "traintitem": [],
|
|
|
},
|
|
|
- bindNormalData:{
|
|
|
+ bindNormalData: {
|
|
|
ownertable: 'sa_workorder_node',
|
|
|
ownerid: 0,
|
|
|
usetype: 'default'
|
|
|
},
|
|
|
- bindContractData:{
|
|
|
+ bindContractData: {
|
|
|
"ownertable": "sa_workorder_node",
|
|
|
"ownerid": 0,
|
|
|
"usetype": "contract",
|
|
|
},
|
|
|
- bindSignNameData:{
|
|
|
+ bindSignNameData: {
|
|
|
"ownertable": "sa_workorder_node",
|
|
|
"ownerid": 0,
|
|
|
"usetype": "signature",
|
|
|
}
|
|
|
},
|
|
|
- async nodeDetail () {
|
|
|
+ async nodeDetail() {
|
|
|
const res = await api._post({
|
|
|
"id": "20230209091103",
|
|
|
- "version":1,
|
|
|
+ "version": 1,
|
|
|
"content": {
|
|
|
- "sa_workorderid":this.data.sa_workorderid,
|
|
|
- "sa_workorder_nodeid":this.data.sa_workorder_nodeid
|
|
|
+ "sa_workorderid": this.data.sa_workorderid,
|
|
|
+ "sa_workorder_nodeid": this.data.sa_workorder_nodeid
|
|
|
}
|
|
|
})
|
|
|
this.setData({
|
|
|
- mainData:res.data[0],
|
|
|
- titems:res.data[0].titems
|
|
|
+ mainData: res.data[0],
|
|
|
+ titems: res.data[0].titems
|
|
|
})
|
|
|
this.setDefaultData()
|
|
|
},
|
|
|
-
|
|
|
// 是否确认
|
|
|
- confirmValue (data) {
|
|
|
+ confirmValue(data) {
|
|
|
this.data.form.confirm_value = data.currentTarget.dataset.item
|
|
|
this.setData({
|
|
|
- form:this.data.form
|
|
|
+ form: this.data.form
|
|
|
})
|
|
|
this.updateNode()
|
|
|
},
|
|
|
-
|
|
|
// 文本信息
|
|
|
- textContent (data) {
|
|
|
+ textContent(data) {
|
|
|
this.data.form.textcontent = data.detail.value
|
|
|
this.setData({
|
|
|
- form:this.data.form
|
|
|
+ form: this.data.form
|
|
|
})
|
|
|
this.updateNode()
|
|
|
},
|
|
|
-
|
|
|
// 是否有偿
|
|
|
- amountPay (data) {
|
|
|
+ amountPay(data) {
|
|
|
this.data.form.amount = data.detail.value
|
|
|
this.setData({
|
|
|
- form:this.data.form
|
|
|
+ form: this.data.form
|
|
|
})
|
|
|
this.updateNode()
|
|
|
},
|
|
|
-
|
|
|
// 备 注
|
|
|
- remarkEdit (data) {
|
|
|
+ remarkEdit(data) {
|
|
|
this.data.form.remarks = data.detail.value
|
|
|
this.setData({
|
|
|
- form:this.data.form
|
|
|
+ form: this.data.form
|
|
|
})
|
|
|
this.updateNode()
|
|
|
},
|
|
|
- confirmBill () {
|
|
|
+ confirmBill() {
|
|
|
this.data.form.isconfirm = 1
|
|
|
this.setData({
|
|
|
- form:this.data.form
|
|
|
+ form: this.data.form
|
|
|
})
|
|
|
this.updateNode()
|
|
|
},
|
|
|
// 更新节点
|
|
|
- async updateNode (e) {
|
|
|
- this.data.form.traintitem = this.data.titems
|
|
|
+ async updateNode(e) {
|
|
|
+ this.data.form.traintitem = this.data.titems
|
|
|
this.data.form.sa_workorderid = this.data.sa_workorderid
|
|
|
this.data.form.sa_workorder_nodeid = this.data.sa_workorder_nodeid
|
|
|
+ this.data.form.team = []
|
|
|
const res = await api._post({
|
|
|
"id": "20230209094203",
|
|
|
- "content":this.data.form
|
|
|
- })
|
|
|
+ "content": this.data.form
|
|
|
+ });
|
|
|
+ if (!this.data.form.team.some(v => v.userid == wx.getStorageSync('userMsg').userid)) {
|
|
|
+ this.setData({
|
|
|
+ teams: [wx.getStorageSync('userMsg').userid]
|
|
|
+ })
|
|
|
+ this.addUser(false);
|
|
|
+ }
|
|
|
if (e && e.currentTarget.dataset.info === 'needBack') {
|
|
|
wx.navigateBack()
|
|
|
} else {
|
|
@@ -113,22 +111,21 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
// 获取输入的数据
|
|
|
- setDefaultData () {
|
|
|
+ setDefaultData() {
|
|
|
let that = this
|
|
|
- Object.keys(this.data.mainData).map((key,index)=>{
|
|
|
- Object.keys(this.data.form).map((key2,index)=>{
|
|
|
+ Object.keys(this.data.mainData).map((key, index) => {
|
|
|
+ Object.keys(this.data.form).map((key2, index) => {
|
|
|
if (key === key2) {
|
|
|
that.data.form[key2] = that.data.mainData[key2]
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
this.setData({
|
|
|
- form:this.data.form
|
|
|
+ form: this.data.form
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
// 跳转到添加人员
|
|
|
- addTrainers () {
|
|
|
+ addTrainers() {
|
|
|
wx.navigateTo({
|
|
|
url: '/Eservice/addTrainers/index',
|
|
|
})
|
|
@@ -139,79 +136,75 @@ Page({
|
|
|
this.data.mainData.trainers = this.data.form.trainers
|
|
|
this.setData({
|
|
|
// form:this.data.form,
|
|
|
- mainData:this.data.mainData
|
|
|
+ mainData: this.data.mainData
|
|
|
})
|
|
|
this.updateNode()
|
|
|
},
|
|
|
// 删除人员
|
|
|
- deleteMenber (data) {
|
|
|
- this.data.mainData.trainers = this.data.mainData.trainers.filter(e=>{
|
|
|
+ deleteMenber(data) {
|
|
|
+ this.data.mainData.trainers = this.data.mainData.trainers.filter(e => {
|
|
|
return e.sa_workorder_node_teamid !== data.detail.sa_workorder_node_teamid
|
|
|
})
|
|
|
this.data.form.trainers = this.data.mainData.trainers
|
|
|
this.setData({
|
|
|
- form:this.data.form,
|
|
|
- mainData:this.data.mainData
|
|
|
+ form: this.data.form,
|
|
|
+ mainData: this.data.mainData
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
this.updateNode()
|
|
|
},
|
|
|
// 跳转到物料添加
|
|
|
- addProduct () {
|
|
|
+ addProduct() {
|
|
|
wx.navigateTo({
|
|
|
url: '/Eservice/serviceMaterial/index',
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
// 添加物料
|
|
|
getAdd(selection) {
|
|
|
-
|
|
|
- this.data.form.traintitem = selection.map(e=>{
|
|
|
+ this.data.form.traintitem = selection.map(e => {
|
|
|
return {
|
|
|
- "itemname":e.itemname,
|
|
|
- "itemid":e.itemid,
|
|
|
- "model":e.model,
|
|
|
- "spec":e.spec,
|
|
|
- "qty":1
|
|
|
+ "itemname": e.itemname,
|
|
|
+ "itemid": e.itemid,
|
|
|
+ "model": e.model,
|
|
|
+ "spec": e.spec,
|
|
|
+ "qty": 1
|
|
|
}
|
|
|
})
|
|
|
this.setData({
|
|
|
- titems:this.data.form.traintitem
|
|
|
+ titems: this.data.form.traintitem
|
|
|
})
|
|
|
this.updateNode()
|
|
|
},
|
|
|
-
|
|
|
// 修改物料数量
|
|
|
- qtyChange (data) {
|
|
|
+ qtyChange(data) {
|
|
|
clearTimeout(this.data.timerid)
|
|
|
- this.data.timerid = setTimeout(()=>{
|
|
|
- this.data.titems.forEach(e=>{
|
|
|
+ this.data.timerid = setTimeout(() => {
|
|
|
+ this.data.titems.forEach(e => {
|
|
|
if (e.itemid == data.detail.itemid) {
|
|
|
e.qty = data.detail.qty
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
this.setData({
|
|
|
titems: this.data.titems
|
|
|
})
|
|
|
this.updateNode()
|
|
|
- },1000)
|
|
|
+ }, 1000)
|
|
|
this.setData({
|
|
|
- timerid:this.data.timerid
|
|
|
+ timerid: this.data.timerid
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
// 删除物料
|
|
|
- deleteMaterial (data) {
|
|
|
+ deleteMaterial(data) {
|
|
|
this.setData({
|
|
|
- titems:this.data.titems.filter(e=>{
|
|
|
+ titems: this.data.titems.filter(e => {
|
|
|
return e.itemid !== data.detail.itemid
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
this.updateNode()
|
|
|
},
|
|
|
-
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
@@ -221,66 +214,79 @@ Page({
|
|
|
this.data.bindNormalData.ownerid = options.id
|
|
|
this.data.bindSignNameData.ownerid = options.id
|
|
|
this.setData({
|
|
|
- bindContractData:this.data.bindContractData,
|
|
|
- bindNormalData:this.data.bindNormalData,
|
|
|
- bindSignNameData:this.data.bindSignNameData,
|
|
|
- sa_workorder_nodeid:options.id,
|
|
|
- sa_workorderid:options.wid,
|
|
|
- stopClick:options.class
|
|
|
+ bindContractData: this.data.bindContractData,
|
|
|
+ bindNormalData: this.data.bindNormalData,
|
|
|
+ bindSignNameData: this.data.bindSignNameData,
|
|
|
+ sa_workorder_nodeid: options.id,
|
|
|
+ sa_workorderid: options.wid,
|
|
|
+ stopClick: options.class
|
|
|
+ })
|
|
|
+ this.nodeDetail();
|
|
|
+ let page = getCurrentPages()[getCurrentPages().length - 2];
|
|
|
+ if (page.__route__ == 'Eservice/workOrderDetail/index') this.setData({
|
|
|
+ workers: page.data.billData.team
|
|
|
})
|
|
|
- this.nodeDetail()
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面初次渲染完成
|
|
|
- */
|
|
|
- onReady() {
|
|
|
-
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面显示
|
|
|
- */
|
|
|
onShow() {
|
|
|
this.setData({
|
|
|
- SignName:true
|
|
|
+ SignName: true
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面隐藏
|
|
|
- */
|
|
|
onHide() {
|
|
|
this.setData({
|
|
|
- SignName:false
|
|
|
+ SignName: false
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
- * 生命周期函数--监听页面卸载
|
|
|
+ * 开始添加成员或者取消添加
|
|
|
*/
|
|
|
- onUnload() {
|
|
|
-
|
|
|
+ showTeamDialog() {
|
|
|
+ this.setData({
|
|
|
+ showTeams: !this.data.showTeams,
|
|
|
+ teams: this.data.mainData.team.map(v => {
|
|
|
+ return v.isleader == 1 ? 0 : v.userid
|
|
|
+ })
|
|
|
+ })
|
|
|
},
|
|
|
-
|
|
|
/**
|
|
|
- * 页面相关事件处理函数--监听用户下拉动作
|
|
|
+ * 选择添加成员
|
|
|
*/
|
|
|
- onPullDownRefresh() {
|
|
|
-
|
|
|
+ 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
|
|
|
+ })
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 页面上拉触底事件的处理函数
|
|
|
- */
|
|
|
- onReachBottom() {
|
|
|
+ addUser(init = true) {
|
|
|
+ api._post({
|
|
|
+ "id": 20220930103603,
|
|
|
+ "content": {
|
|
|
+ ownertable: 'sa_workorder_node',
|
|
|
+ ownerid: this.data.mainData.sa_workorder_nodeid,
|
|
|
+ "userids": this.data.teams
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("添加成员", res)
|
|
|
+ wx.showToast({
|
|
|
+ title: res.msg == '成功' ? '修改成功' : res.msg,
|
|
|
+ icon: "none",
|
|
|
+ mask: true
|
|
|
+ });
|
|
|
+ if (res.msg == '成功') {
|
|
|
+ this.nodeDetail();
|
|
|
+ if (init) this.showTeamDialog();
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 用户点击右上角分享
|
|
|
- */
|
|
|
- onShareAppMessage() {
|
|
|
-
|
|
|
- }
|
|
|
})
|