detail.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../utils/currency"),
  3. CNY = value => currency(value, {
  4. symbol: "¥",
  5. precision: 2
  6. }).format();
  7. Page({
  8. data: {
  9. loading: true,
  10. isLeader: false, //是否为负责人
  11. tabsActive: 0, //tabs 选中项
  12. sa_doctorid: 0,
  13. sColors: getApp().globalData.sColors,
  14. },
  15. onLoad(options) {
  16. const appAuth = wx.getStorageSync('auth').wdoctors;
  17. let tabsList = [{
  18. label: "详细信息",
  19. icon: "icon-tabxiangxixinxi1"
  20. }, {
  21. label: "附件",
  22. icon: "icon-tabfujian1",
  23. model: "#Files"
  24. }, {
  25. label: "操作",
  26. icon: "icon-tabcaozuojilu1",
  27. model: "#Record"
  28. }];
  29. if (appAuth.isdatafollowup) {
  30. tabsList.unshift({
  31. label: "跟进动态",
  32. icon: "icon-tabgenjinjilu",
  33. model: "#Trace"
  34. })
  35. }
  36. console.log("appAuth", appAuth)
  37. this.setData({
  38. sa_doctorid: options.id,
  39. tabsList,
  40. appAuth
  41. })
  42. this.getDetail();
  43. getApp().globalData.Language.getLanguagePackage(this);
  44. },
  45. /* 获取详情 */
  46. getDetail() {
  47. /* 基本信息 */
  48. _Http.basic({
  49. "id": 2025102116474702,
  50. "content": {
  51. sa_doctorid: this.data.sa_doctorid
  52. },
  53. }).then(res => {
  54. console.log("详情", res)
  55. if (res.code != '1') return wx.showToast({
  56. title: res.data,
  57. icon: "none"
  58. })
  59. this.setPreview(res);
  60. this.setData({
  61. loading: false,
  62. detail: res.data,
  63. })
  64. //获取标签
  65. if (this.data.appAuth.isdatatag) this.getTags();
  66. if (this.data.appAuth.isdatateam) this.getGroup()
  67. this.setTabbar();
  68. this.partialRenewal();
  69. });
  70. },
  71. setPreview(res) {
  72. /* 摘要信息 */
  73. let briefs = [{
  74. label: "联系方式",
  75. value: res.data.phonenumber
  76. }, {
  77. label: "职称",
  78. value: res.data.professional
  79. }, {
  80. label: "所属科室",
  81. value: res.data.hospitaldepname
  82. }, {
  83. label: "是否科室负责人",
  84. value: res.data.isleader == 0 ? '否' : '是'
  85. }, {
  86. label: "负责人",
  87. value: res.data.leader.length ? res.data.leader[0].name : ''
  88. }, {
  89. label: "所属医院",
  90. value: res.data.enterprisename
  91. }, {
  92. label: "备注",
  93. value: res.data.remarks
  94. }];
  95. /* 基本信息 */
  96. let list1 = [{
  97. label: "联系方式",
  98. value: res.data.phonenumber
  99. }, {
  100. label: "职称",
  101. value: res.data.professional
  102. }, {
  103. label: "所属科室",
  104. value: res.data.hospitaldepname
  105. }, {
  106. label: "是否科室负责人",
  107. value: res.data.isleader == 0 ? '否' : '是'
  108. }, {
  109. label: "负责人",
  110. value: res.data.leader.length ? res.data.leader[0].name : ''
  111. }, {
  112. label: "所属医院",
  113. value: res.data.enterprisename
  114. }, {
  115. label: "备注",
  116. value: res.data.remarks
  117. }];
  118. /* 系统信息 */
  119. let list2 = [{
  120. label: "创建人",
  121. value: res.data.createby
  122. }, {
  123. label: "创建时间",
  124. value: res.data.createdate
  125. }, {
  126. label: "最近编辑人",
  127. value: res.data.changeby
  128. }, {
  129. label: "最近编辑时间",
  130. value: res.data.changedate
  131. }, {
  132. label: "删除原因",
  133. value: res.data.deletereason
  134. }, {
  135. label: "转手次数",
  136. value: res.data.leader[0] ? res.data.leader[0].leadernum : 0
  137. }];
  138. this.setData({
  139. briefs,
  140. list1,
  141. list2
  142. });
  143. },
  144. //详情按钮回调
  145. tabbarOnClick({
  146. detail
  147. }) {
  148. let data = JSON.parse(JSON.stringify(this.data.detail)),
  149. that = this;
  150. switch (detail.label) {
  151. case "编辑":
  152. data.sa_customersid = data.enterprisename ? [data.enterprisename, [data.sa_customersid]] : "";
  153. wx.navigateTo({
  154. url: `/prsx/doctors/insert?data=${JSON.stringify(data)}`,
  155. })
  156. break;
  157. case "跟进":
  158. that.selectComponent("#Trace").toAdd()
  159. break;
  160. case "删除":
  161. wx.showModal({
  162. content: `是否确定删除'${data.hospitaldepname}'?`,
  163. complete: (res) => {
  164. if (res.confirm) _Http.basic({
  165. "content": {
  166. "sa_doctorid": data.sa_doctorid
  167. },
  168. "id": 2025102116480402
  169. }).then(res => {
  170. console.log("删除医生", res)
  171. wx.showToast({
  172. title: res.code != '1' ? res.msg : '删除成功',
  173. icon: "none",
  174. mask: res.code == '1'
  175. })
  176. if (res.code != '1') return;
  177. setTimeout(() => {
  178. wx.navigateBack()
  179. }, 300)
  180. })
  181. }
  182. })
  183. break;
  184. case "更换负责人":
  185. wx.navigateTo({
  186. url: `/pages/group/select?data=${JSON.stringify({
  187. ownertable:"sa_doctor",
  188. ownerid:this.data.sa_doctorid,
  189. })}&radio=true&principal=true`,
  190. })
  191. break;
  192. default:
  193. console.log(detail)
  194. break;
  195. }
  196. },
  197. /* 更换负责人 */
  198. handelSubmit(arr) {
  199. const that = this;
  200. wx.showModal({
  201. title: getApp().globalData.Language.getMapText('提示'),
  202. content: getApp().globalData.Language.getMapText('是否确认更换负责人'),
  203. complete: ({
  204. confirm
  205. }) => {
  206. if (confirm) wx.showModal({
  207. title: getApp().globalData.Language.getMapText('提示'),
  208. content: getApp().globalData.Language.getMapText('是否参与该数据的后续工作'),
  209. cancelText: getApp().globalData.Language.getMapText('不参与'),
  210. confirmText: getApp().globalData.Language.getMapText('参与'),
  211. complete: (s) => {
  212. _Http.basic({
  213. "id": 20220930103701,
  214. "content": {
  215. ownertable: "sa_doctor",
  216. ownerid: that.data.sa_doctorid,
  217. userid: arr[0],
  218. isaddoldleader: s.confirm ? 1 : 0
  219. }
  220. }).then(res => {
  221. console.log("更换负责人", res)
  222. if (res.code != '1') return wx.showToast({
  223. title: res.data,
  224. icon: "none"
  225. });
  226. wx.showToast({
  227. title: getApp().globalData.Language.getMapText('更换成功'),
  228. icon: "none",
  229. mask: true
  230. });
  231. getCurrentPages().forEach(v => {
  232. if (['packageA/setclient/index'].includes(v.__route__)) v.getList(true)
  233. })
  234. setTimeout(() => {
  235. wx.navigateBack({
  236. delta: 2
  237. });
  238. }, 300)
  239. })
  240. }
  241. })
  242. }
  243. })
  244. },
  245. /* 底部功能 */
  246. async setTabbar() {
  247. let detail = this.data.detail,
  248. isAdmin = this.data.appAuth.options.includes("admin") ? true : false,
  249. isLeader = detail.leader.some(some => some.userid == wx.getStorageSync('userMsg').userid),
  250. editdataleader = isLeader ? 1 : 0,
  251. tabbarList = [],
  252. appAuth = this.data.appAuth;
  253. console.log("isAdmin", isAdmin)
  254. if (isLeader || isAdmin) {
  255. tabbarList.push({
  256. icon: "color-bianji",
  257. label: "编辑"
  258. })
  259. tabbarList.push({
  260. icon: "icon-shanchu",
  261. label: "删除"
  262. })
  263. }
  264. if (appAuth.isdatafollowup) {
  265. tabbarList.push({
  266. icon: "color-genjin",
  267. label: "跟进"
  268. });
  269. }
  270. this.setData({
  271. tabbarList,
  272. isLeader
  273. })
  274. },
  275. //tabs 切换
  276. tabsChange({
  277. detail
  278. }) {
  279. this.setData({
  280. tabsActive: detail
  281. });
  282. this.partialRenewal();
  283. },
  284. //局部数据更新 tabs
  285. partialRenewal(init = false) {
  286. let model = this.data.tabsList[this.data.tabsActive].model;
  287. if (model) {
  288. let Component = this.selectComponent(model),
  289. {
  290. total,
  291. pageNumber,
  292. pageTotal
  293. } = Component.data.content,
  294. id = model == "#Clue" ? this.data.detail.sa_doctorid : this.data.detail.sys_enterpriseid;
  295. if (model == "#Files") init = true;
  296. if (total == null || init) {
  297. Component.getList(id, init);
  298. } else if (pageNumber <= pageTotal) {
  299. Component.getList(id, false);
  300. }
  301. }
  302. },
  303. //更新标签
  304. getTags() {
  305. this.selectComponent("#Tags").getTags()
  306. },
  307. //更新团队成员
  308. getGroup() {
  309. this.selectComponent("#Group").getList().then(this.setTabbarList)
  310. },
  311. onReachBottom() {
  312. this.partialRenewal();
  313. },
  314. onUnload() {
  315. getCurrentPages().forEach(page => {
  316. if (page.__route__ == 'prsx/doctors/index') {
  317. let content = JSON.parse(JSON.stringify(page.data.content));
  318. content.pageSize = (content.pageNumber - 1) * content.pageSize;
  319. content.pageNumber = 1;
  320. _Http.basic({
  321. id: '2025102208523002',
  322. content
  323. }).then(res => {
  324. console.log("更新医生列表", res);
  325. if (res.code == '1') {
  326. page.setData({
  327. list: res.data,
  328. "content.total": res.total
  329. })
  330. }
  331. })
  332. } else if (page.__route__ == 'prsx/department/detail') {
  333. page.selectComponent("#Doctors").getList(page.data.detail.sa_hospitaldepid, true)
  334. } else if (page.__route__ == 'prsx/hospital/detail') {
  335. page.selectComponent("#Doctors").getList('', true)
  336. }
  337. })
  338. }
  339. })