| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- const _Http = getApp().globalData.http;
- Component({
- options: {
- addGlobalClass: true
- },
- properties: {
- sc_workorderid: {
- type: String,
- value: ''
- }
- },
- data: {
- hasApplicationPerm: false,
- delShow: false,
- reason: {
- voidreason: ""
- },
- id: 2026052911075602,
- content: {
- nocache: true,
- pageNumber: 1,
- pageSize: 20,
- where: {
- condition: "",
- }
- },
- list: [],
- showSearch: false,
- focus: false,
- condition: ""
- },
- lifetimes: {
- attached: function () {
- getApp().globalData.Language.getLanguagePackage(this)
- const auth = wx.getStorageSync('auth').wWorkOrder;
- const hasApplicationPerm = auth.options.some(v => v == 'application');
- this.setData({ hasApplicationPerm });
- },
- },
- methods: {
- getList(sc_workorderid, init = false) {
- let content = {
- ...this.data.content,
- sc_workorderid: sc_workorderid || this.properties.sc_workorderid
- };
- _Http.init(content, init).then(content => {
- _Http.basic({
- id: this.data.id,
- content
- }).then(res => {
- if (res.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- this.setData({
- content: _Http.paging(content, res),
- list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
- })
- })
- })
- },
- handleRefuse(e) {
- const sc_warrantycard_applyid = e.currentTarget.dataset.id;
- this.setData({
- delShow: true,
- currentApplyId: sc_warrantycard_applyid
- })
- },
- onCancel() {
- this.setData({
- delShow: false,
- reason: {
- voidreason: ""
- }
- })
- },
- areaInput(e) {
- this.data.reason[e.currentTarget.dataset.name] = e.detail.value;
- },
- // 拒绝
- onSuspend() {
- let voidreason = this.data.reason.voidreason;
- if (voidreason == '') return wx.showToast({
- title: getApp().globalData.Language.getMapText("请填写拒绝原因"),
- icon: "none"
- })
- _Http.basic({
- "content": {
- "sc_workorderid": this.properties.sc_workorderid,
- "sc_warrantycard_applyid": this.data.currentApplyId,
- "isAgreed": 0,
- "reject_reason": voidreason
- },
- "id": 2026052910290102,
- }).then(res => {
- if (res.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- getApp().globalData.Language.showToast("拒绝成功");
- this.setData({
- delShow: false,
- reason: { voidreason: "" }
- });
- this.getList(this.properties.sc_workorderid, true);
- this.triggerEvent('refreshdetail');
- }).catch(err => {
- wx.showToast({
- title: getApp().globalData.Language.getMapText("操作失败"),
- icon: "none"
- });
- })
- },
- handleAgree(e) {
- const sc_warrantycard_applyid = e.currentTarget.dataset.id;
- wx.showModal({
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText(`是否同意该工单的质保卡申请`) + '?',
- confirmText: getApp().globalData.Language.getMapText('确定同意'),
- cancelText: getApp().globalData.Language.getMapText('取消'),
- success: ({
- confirm
- }) => {
- if (!confirm) return;
- _Http.basic({
- "content": {
- "sc_workorderid": this.properties.sc_workorderid,
- "sc_warrantycard_applyid": sc_warrantycard_applyid,
- "isAgreed": 1
- },
- "id": 2026052910290102,
- }).then(res => {
- if (res.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- getApp().globalData.Language.showToast("同意成功");
- this.getList(this.properties.sc_workorderid, true);
- this.triggerEvent('refreshdetail');
- }).catch(err => {
- wx.showToast({
- title: getApp().globalData.Language.getMapText("操作失败"),
- icon: "none"
- });
- })
- }
- })
- },
- toSearch() {
- if (this.data.showSearch && this.data.content.where.condition) {
- // 点击关闭搜索框 清空搜索条件,刷新列表
- this.data.content.where.condition = '';
- this.getList("", true); // init=true 重置分页
- } else if (this.data.condition) {
- // 输入了关键词,搜索
- this.data.content.where.condition = this.data.condition;
- this.getList("", true);
- }
- this.setData({
- showSearch: !this.data.showSearch
- })
- setTimeout(() => {
- this.setData({
- focus: this.data.showSearch
- })
- }, 300)
- },
- onChange({
- detail
- }) {
- this.data.condition = detail;
- },
- onSearch({
- detail
- }) {
- this.data.content.where.condition = detail;
- this.getList("", true)
- },
- }
- });
|