|
|
@@ -0,0 +1,124 @@
|
|
|
+const _Http = getApp().globalData.http;
|
|
|
+
|
|
|
+Component({
|
|
|
+ options: {
|
|
|
+ addGlobalClass: true
|
|
|
+ },
|
|
|
+ properties: {
|
|
|
+ sc_workorderid: {
|
|
|
+ type: String,
|
|
|
+ value: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ id: 20220930103501,
|
|
|
+ version: 1,
|
|
|
+ content: {
|
|
|
+ ownertable: "sc_workorder",
|
|
|
+ ownerid: "",
|
|
|
+ where: {
|
|
|
+ condition: "",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ list: [],
|
|
|
+ showSearch: false,
|
|
|
+ focus: false,
|
|
|
+ condition: ""
|
|
|
+ },
|
|
|
+ lifetimes: {
|
|
|
+ attached: function () {
|
|
|
+ getApp().globalData.Language.getLanguagePackage(this)
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getList(sc_workorderid, init = false) {
|
|
|
+ let ownerid = sc_workorderid || this.properties.sc_workorderid;
|
|
|
+ // ownerid变化时强制刷新,避免切换工单后拼接旧数据
|
|
|
+ if (ownerid && ownerid !== this.data.content.ownerid) {
|
|
|
+ init = true;
|
|
|
+ }
|
|
|
+ let content = {
|
|
|
+ ...this.data.content,
|
|
|
+ ownerid
|
|
|
+ };
|
|
|
+ _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"
|
|
|
+ });
|
|
|
+ // 该接口不分页,始终替换列表,不拼接旧数据
|
|
|
+ let tableData = this.buildTableData(res.data);
|
|
|
+ this.setData({
|
|
|
+ content: _Http.paging(content, res),
|
|
|
+ list: res.data,
|
|
|
+ tableData: tableData
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ buildTableData(list) {
|
|
|
+ const result = [];
|
|
|
+ if (!Array.isArray(list) || list.length === 0) return result;
|
|
|
+ list.forEach((group) => {
|
|
|
+ const leader = (group.teamleader && group.teamleader[0]) || {};
|
|
|
+ const members = group.team || [];
|
|
|
+ // 组长行
|
|
|
+ result.push({
|
|
|
+ name: leader.name || group.teamname || "--",
|
|
|
+ phonenumber: leader.phonenumber || "--",
|
|
|
+ position: leader.position || "--",
|
|
|
+ isLeader: true,
|
|
|
+ });
|
|
|
+ // 组员行
|
|
|
+ members.forEach((member) => {
|
|
|
+ result.push({
|
|
|
+ name: member.name || "--",
|
|
|
+ phonenumber: member.phonenumber || "--",
|
|
|
+ position: member.position || "--",
|
|
|
+ isLeader: false,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+ },
|
|
|
+ callPhone(e) {
|
|
|
+ wx.makePhoneCall({
|
|
|
+ phoneNumber: e.currentTarget.dataset.number
|
|
|
+ })
|
|
|
+ },
|
|
|
+ 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)
|
|
|
+ },
|
|
|
+ }
|
|
|
+});
|