| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557 |
- const _Http = getApp().globalData.http;
- Page({
- data: {
- tabColorS: {
- 售前: {
- bgColor: "#E1EAFE",
- color: "#3874F6"
- },
- 售中: {
- bgColor: "#FEF0E1",
- color: "#F69E38"
- },
- 售后: {
- bgColor: "#FCE4E4",
- color: "#ED4949"
- },
- 紧急: {
- bgColor: "#FCE4E4",
- color: "#ED4949"
- },
- 历史售后: {
- bgColor: "#eeeeee",
- color: "#888888"
- }
- },
- tabsList: [{
- label: "工单服务商品",
- model: "#WorkOrderProduct",
- idname: "sa_workorderid",
- color: "#2AA520"
- }, {
- label: "工序详情",
- model: "#WorkOrderNodes",
- idname: "sa_workorderid",
- color: "#2AA520"
- }, {
- label: "工单物料",
- model: "#WorkOrderMaterial",
- idname: "sa_workorderid",
- color: "#2AA520"
- }, {
- label: "服务确认单",
- model: "#WorkOrderNotarizeBill",
- idname: "sa_workorderid",
- color: "#2AA520"
- }, {
- label: "服务团队",
- idname: "sa_workorderid",
- color: "#2AA520"
- }, {
- label: "工单信息",
- idname: "sa_workorderid",
- color: "#2AA520"
- }],
- tabsActive: 0,
- reason: {
- abortreason: ""
- },
- abortreasonShow: false,
- takeOrderShow: false,
- isqQuery: false,
- takeOrderForm: {
- isout: "否"
- }
- },
- onLoad(options) {
- console.log("options",options)
- getApp().globalData.Language.getLanguagePackage(this, '工单详情');
- this.setData({
- sa_workorderid: options.id
- })
- this.getDetail()
- },
- getDetail() {
- _Http.basic({
- "id": 20230208140103,
- "content": {
- "sa_workorderid": this.data.sa_workorderid,
- nocache: true
- },
- }).then(async res => {
- console.log("工单详情", res)
- if (res.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- })
- this.setData({
- detail: res.data
- })
- if (res.data.actiontype == '非工序模板') {
- this.setData({
- tabsList: this.data.tabsList.filter(v => ['工单服务商品', '服务确认单', '服务团队', '工单信息', '关联改善单'].includes(v.label))
- })
- } else {
- this.setData({
- tabsList: this.data.tabsList.filter(v => ['工序详情', '工单物料', '服务确认单', '服务团队', '工单信息', '关联改善单'].includes(v.label))
- })
- }
- this.selectComponent("#WorkOrderPview").setPreview(res);
- this.setTabbar()
- this.partialRenewal()
- const appAuth = wx.getStorageSync('auth').workBill;
- if (appAuth.options.some(v => v == 'applicationForm')) await this.getServiceDetail(res.data.sa_serviceorderid)
- if (!this.data.tabsList.some(v => v.label == '附件')) {
- let list = [{
- label: "附件",
- color: "#ED4949",
- model: "#Files"
- }, {
- label: "操作记录",
- color: "#ED4949",
- model: "#Record"
- }]
- if (appAuth.options.some(v => v == 'improve')) list.unshift({
- label: "关联改善单",
- idname: "sa_workorderid",
- color: "#F48403",
- model: "#Improvement"
- })
- this.setData({
- tabsList: this.data.tabsList.concat(list)
- })
- }
- })
- },
- getServiceDetail(id) {
- if (!id) return;
- return new Promise((resolve) => {
- _Http.basic({
- "id": 20230206091603,
- "content": {
- "sa_serviceorderid": id
- },
- }).then(res => {
- console.log("申请单详情", res)
- resolve()
- if (res.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- })
- let tabsList = [{
- label: "申请信息",
- idname: "sa_serviceorderid",
- color: "#3874F6"
- }, {
- label: "受理信息",
- idname: "sa_serviceorderid",
- color: "#3874F6"
- }];
- if (['售中', "售后"].includes(res.data.servicetype)) {
- tabsList.unshift({
- label: "服务商品",
- model: "#ServiceProduct",
- idname: "sa_serviceorderid",
- color: "#3874F6"
- })
- }
- this.setData({
- tabsList: this.data.tabsList.some(v => v.label == '申请信息') ? this.data.tabsList : this.data.tabsList.concat(tabsList),
- serviceDetail: res.data
- })
- this.selectComponent("#ServicePview1").setPreview(res);
- this.selectComponent("#ServicePview2").setPreview(res);
- })
- })
- },
- areaInput(e) {
- this.data.reason[e.currentTarget.dataset.name] = e.detail.value;
- },
- addConfirmBill() {
- let page = this.selectComponent("#WorkOrderNotarizeBill");
- page.setData({
- sa_workorderid: this.data.detail.sa_workorderid
- })
- page.addConfirmBill()
- },
- onCancel() {
- this.setData({
- abortreasonShow: false,
- backreasonShow: false,
- takeOrderShow: false,
- takeOrderForm: {
- isout: "否"
- }
- })
- },
- onIsOutChange(e) {
- this.setData({
- 'takeOrderForm.isout': e.detail
- })
- },
- onTake() {
- let that = this;
- setTimeout(() => {
- let isout = that.data.takeOrderForm.isout === '是' ? 1 : 0;
- _Http.basic({
- "content": {
- "sa_workorderid": that.data.detail.sa_workorderid,
- "isout": isout,
- userid: that.data.detail.team.find(v => v.isleader).userid
- },
- "id": 20230210101103,
- }).then(res => {
- getApp().globalData.Language.showToast(res.code == '1' ? "接单成功" : res.msg)
- if (res.code == 1) {
- that.getDetail();
- that.onCancel();
- }
- })
- });
- },
- // 中止
- onSuspend() {
- let that = this;
- setTimeout(() => {
- let abortreason = that.data.reason.abortreason;
- if (abortreason == '') return wx.showToast({
- title: getApp().globalData.Language.getMapText("请说明中止原因"),
- icon: "none"
- })
- _Http.basic({
- "content": {
- "sa_workorderid": that.data.detail.sa_workorderid,
- abortreason
- },
- "id": 2026012714282702,
- }).then(res => {
- getApp().globalData.Language.showToast(res.code == '1' ? "中止成功" : res.msg)
- if (res.code == 1) that.getDetail();
- })
- });
- },
- tabbarOnClick(e) {
- let that = this,
- detail = this.data.detail;
- switch (e.detail.label) {
- case '转单':
- let leader = '';
- try {
- leader = detail.team.find(v => v.isleader).userid || 0
- } catch (error) {
- }
- _Http.basic({
- id: 20230213143003,
- content: {
- pageSize: 9999
- }
- }).then(res => {
- console.log("转单", res)
- if (res.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- })
- this.setData({
- users: res.data.map(v => {
- v.disabled = v.userid == leader
- return v
- })
- })
- })
- break;
- case '编辑':
- wx.navigateTo({
- url: `/E-service/workOrder/insert`
- })
- break;
- case '确认信息':
- wx.navigateTo({
- url: '/E-service/workOrder/confirm?id=' + detail.sa_workorderid
- })
- break;
- case '接单':
- this.setData({
- takeOrderShow: true
- })
- // wx.navigateTo({
- // url: `/E-service/workOrder/takeOrder`
- // })
- break;
- case '中止':
- this.setData({
- abortreasonShow: true
- })
- break;
- case '暂停':
- wx.showModal({
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText(`确认暂停当前工单吗`) + '?',
- confirmBtn: getApp().globalData.Language.getMapText('确定'),
- cancelBtn: getApp().globalData.Language.getMapText('取消'),
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "content": {
- "sa_workorderid": detail.sa_workorderid
- },
- "id": "20230209144603",
- }).then(res => {
- getApp().globalData.Language.showToast(res.code == '1' ? "暂停成功" : res.msg)
- that.getDetail()
- })
- }
- })
- break;
- case '完结工单':
- wx.showModal({
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText(`确认完结工单吗`) + '?',
- confirmBtn: getApp().globalData.Language.getMapText('确定'),
- cancelBtn: getApp().globalData.Language.getMapText('取消'),
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "content": {
- "sa_workorderid": detail.sa_workorderid
- },
- "id": "20230209144903",
- }).then(res => {
- getApp().globalData.Language.showToast(res.code == '1' ? "完结成功" : res.msg)
- that.getDetail()
- })
- }
- })
- break;
- case '开始工单':
- wx.showModal({
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText(`确认开始工单吗`) + '?',
- confirmBtn: getApp().globalData.Language.getMapText('确定'),
- cancelBtn: getApp().globalData.Language.getMapText('取消'),
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "content": {
- "sa_workorderid": detail.sa_workorderid
- },
- "id": "20230209144503",
- }).then(res => {
- getApp().globalData.Language.showToast(res.code == '1' ? "开始成功" : res.msg)
- that.getDetail()
- })
- }
- })
- break;
- case '启用':
- wx.showModal({
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText(`确认启用当前工单吗`) + '?',
- confirmBtn: getApp().globalData.Language.getMapText('确定'),
- cancelBtn: getApp().globalData.Language.getMapText('取消'),
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "content": {
- "sa_workorderid": detail.sa_workorderid
- },
- "id": "20230209144703",
- }).then(res => {
- getApp().globalData.Language.showToast(res.code == '1' ? "启用成功" : res.msg)
- that.getDetail()
- })
- }
- })
- break;
- }
- },
- onSelectLeader({
- detail
- }) {
- const that = this;
- wx.showModal({
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText(`是否确认选择`) + getApp().globalData.Language.getMapText(detail.name) + getApp().globalData.Language.getMapText(`执行工单`) + '?',
- confirmBtn: getApp().globalData.Language.getMapText('确定'),
- cancelBtn: getApp().globalData.Language.getMapText('取消'),
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "content": {
- "sa_workorderid": that.data.detail.sa_workorderid,
- "userid": detail.userid
- },
- "id": 2026012714183302,
- }).then(res => {
- getApp().globalData.Language.showToast(res.code == '1' ? "操作成功" : res.msg)
- if (res.code == 1) {
- that.getDetail()
- that.clearUsers()
- }
- })
- }
- })
- },
- clearUsers() {
- this.setData({
- "users": []
- })
- },
- /* 底部功能 */
- async setTabbar() {
- let status = this.data.detail.status,
- tabbarList = [],
- isLeader = false,
- isqQuery = this.data.isqQuery,
- isworkleader = this.data.isworkleader || false;
- try {
- isLeader = this.data.detail.team.find(v => v.isleader).userid == wx.getStorageSync("userMsg").userid
- } catch (error) {}
- let options = {
- 编辑: {
- icon: "icon-bianji2",
- label: "编辑"
- },
- 转单: {
- icon: "icon-dibu-biangengchengjiaozhuangtai",
- label: "转单"
- },
- 确认信息: {
- icon: "icon-jiaoqiqueren",
- label: "确认信息"
- },
- 接单: {
- icon: "icon-a-tonggaoshujuxiazailiang",
- label: "接单"
- },
- 开始工单: {
- icon: "icon-huifu1",
- label: "开始工单"
- },
- 暂停: {
- icon: "icon-zanhuan",
- label: "暂停"
- },
- 完结工单: {
- icon: "icon-dibu-chengjiao",
- label: "完结工单"
- },
- 启用: {
- icon: "icon-quxiaozanhuan",
- label: "启用"
- },
- 中止: {
- icon: "icon-dibu-zuofei",
- label: "中止"
- }
- };
- if (!isqQuery) await _Http.basic({
- "id": 2025062416033402,
- "content": {
- "userid": wx.getStorageSync('userMsg').userid,
- "sa_workorderid": this.data.detail.sa_workorderid,
- },
- }).then(res => {
- console.log("重新是否服务主管", res)
- if (res.code == 1) {
- isworkleader = res.data.isworkleader
- isLeader = res.data.isteamleader
- this.setData({
- isworkleader: res.data.isworkleader,
- isqQuery: true,
- isLeader
- })
- }
- })
- let statusOptions = {
- 待接单: ['接单', '中止'],
- 待开始: ['开始工单', '中止'],
- 进行中: ['完结工单', '暂停', '中止'],
- 暂停: ['启用', '中止'],
- };
- if (statusOptions[status]) {
- if (!isLeader) statusOptions[status] = [];
- if ((isworkleader || isLeader) && status == '待接单') {
- statusOptions[status] = statusOptions[status] = ['确认信息', '转单'].concat(statusOptions[status])
- }
- if (isLeader || isworkleader) {
- if (status == '待开始') statusOptions[status].unshift("确认信息");
- statusOptions[status].unshift("编辑");
- }
- tabbarList = statusOptions[status].map(v => options[v]);
- }
- this.setData({
- tabbarList
- })
- },
- //tabs 切换
- tabsChange({
- detail
- }) {
- this.setData({
- tabsActive: detail
- });
- this.partialRenewal();
- },
- //局部数据更新 tabs
- partialRenewal(init = false) {
- try {
- let ac = this.data.tabsList[this.data.tabsActive];
- let model = ac.model;
- if (model) {
- let Component = this.selectComponent(model),
- {
- total,
- pageNumber,
- pageTotal
- } = Component.data.content,
- id = this.data.detail[ac.idname || 'sa_workorderid'];
- if (total == null || init) {
- Component.getList(id, init);
- } else if (pageNumber <= pageTotal) {
- Component.getList(id, false);
- }
- }
- } catch (error) {
- }
- },
- onReachBottom() {
- this.partialRenewal();
- },
- callPhone(e) {
- wx.makePhoneCall({
- phoneNumber: e.currentTarget.dataset.number
- })
- },
- onUnload() {
- getCurrentPages().forEach(page => {
- if (page.__route__ == 'E-service/workOrder/index') {
- let content = JSON.parse(JSON.stringify(page.data.content));
- content.pageSize = (content.pageNumber - 1) * content.pageSize;
- content.pageNumber = 1;
- _Http.basic({
- id: page.data.id,
- content
- }).then(res => {
- console.log("更新列表", res);
- if (res.code == '1') {
- page.setData({
- list: res.data,
- "content.total": res.total
- })
- }
- })
- } else {}
- })
- }
- })
|