const _Http = getApp().globalData.http; Component({ properties: { disabled: { type: Boolean, value: false } }, options: { addGlobalClass: true }, data: { sa_hospitaldepid: 0, content: { nocache: true, pageNumber: 1, pageSize: 10, pageTotal: 1, total: null, where: { condition: "" } }, list: [], showSearch: false, focus: false, condition: "", stages: [], showAction: false }, methods: { changeStage(e) { const { item } = e.currentTarget.dataset, that = this; this.setData({ stages: this.data.stages.map(v => { v.color = v.stagename == item.stagename ? '#3874F6' : '' return v }), showAction: true, changeItem: item }) }, onSelect({ detail }) { let item = this.data.changeItem, that = this; if (detail.color) return that.onCancel() wx.showModal({ content: `是否确定将阶段修改为“${detail.stagename}”?`, complete: ({ confirm }) => { if (confirm) _Http.basic({ "id": "2025102110224102", "content": { sa_hospitaldep_itemid: item.sa_hospitaldep_itemid, sa_devstageid: detail.sa_devstageid }, }).then(res => { wx.showToast({ title: res.code == 1 ? '修改成功' : res.msg, icon: "none" }) if (res.code == 1) { that.getList('', true) that.onCancel() getCurrentPages().find(v => v.__route__ == 'prsx/department/detail').getDetail() } }) } }) }, onCancel() { this.setData({ showAction: false, changeItem: null }) }, getList(id, init = false) { let content = { ...this.data.content, sa_hospitaldepid: id || this.data.sa_hospitaldepid }; if (init) { content.pageNumber = 1 content.pageTotal = 1 } if (this.data.stages.length == 0) _Http.basic({ "content": { "pageNumber": 1, "pageSize": 999, "where": { "condition": "" } }, "id": 2025100916245502, }).then(res => { console.log("获取阶段列表", res) if (res.code != 1) return; this.setData({ stages: res.data.map(v => { v.name = v.stagename return v }) }) }) _Http.basic({ "id": 2025102110205102, content }).then(res => { console.log("科室推荐产品", res) if (res.code != '1') return wx.showToast({ title: res.data, icon: "none" }); let list = res.data.map(v => { v.cover = v.attinfos.length ? _Http.getSpecifiedImage(v.attinfos[0]) : '' return v }) this.setData({ "content.pageNumber": res.pageNumber + 1, "content.pageTotal": res.pageTotal, "content.total": res.total, list: res.pageNumber == 1 ? list : this.data.list.concat(list), sa_hospitaldepid: content.sa_hospitaldepid }) }) }, insetr() { let params = { "id": "2025102110220202", "content": { "sa_hospitaldepid": this.data.sa_hospitaldepid, "where": { "condition": "", } } }; wx.navigateTo({ url: `/prsx/select/product/index?params=${JSON.stringify(params)}&radio=true` }) let that = this; _Http.handleSelect = ({ item }) => { wx.showModal({ content: `是否确定添加“${item.itemname}”到推荐产品?`, complete: ({ confirm }) => { if (confirm) _Http.basic({ "id": "2025102110170902", "content": { "sa_hospitaldepid": that.data.sa_hospitaldepid, "itemids": [item.itemid] }, }).then(res => { wx.showToast({ title: res.code == 1 ? '添加成功' : res.msg, icon: "none" }) if (res.code == 1) { that.getList('', true) getCurrentPages().find(v => v.__route__ == 'prsx/select/product/index').uploadList() } }) } }) } }, deleteItem(e) { const { item } = e.currentTarget.dataset, that = this; wx.showModal({ content: `是否确定删除“${item.itemname}”?`, complete: ({ confirm }) => { if (confirm) _Http.basic({ "id": "2025102110202602", "content": { sa_hospitaldep_itemid: item.sa_hospitaldep_itemid }, }).then(res => { wx.showToast({ title: res.code == 1 ? '删除成功' : res.msg, icon: "none" }) if (res.code == 1) { that.getList('', true) } }) } }) }, toSearch() { if (this.data.showSearch && this.data.content.where.condition) { this.data.content.where.condition = ''; this.getList("", true); } else if (this.data.condition) { this.data.content.where.condition = this.data.condition; this.setData({ 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) }, } })