detail.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. loading: true,
  5. isLeader: false, //是否为负责人
  6. tabsActive: 1, //tabs 选中项
  7. sa_customersid: 0,
  8. sColors: getApp().globalData.sColors,
  9. deletereasonShow: false,
  10. deletereason: "",
  11. },
  12. onLoad(options) {
  13. const appAuth = wx.getStorageSync('auth').wCustomer;
  14. this.setData({
  15. sa_customersid: options.id,
  16. appAuth
  17. })
  18. this.getDetail();
  19. getApp().globalData.Language.getLanguagePackage(this, '医院详情');
  20. },
  21. /* 获取详情 */
  22. getDetail() {
  23. /* 基本信息 */
  24. _Http.basic({
  25. "id": 20221012164302,
  26. "content": {
  27. sa_customersid: this.data.sa_customersid
  28. },
  29. }).then(res => {
  30. console.log("详情", res)
  31. if (res.code != '1') return wx.showToast({
  32. title: res.data,
  33. icon: "none"
  34. })
  35. this.setPreview(res);
  36. this.setData({
  37. loading: false,
  38. detail: res.data,
  39. })
  40. //获取标签
  41. if (this.data.appAuth.isdatatag) this.getTags();
  42. if (this.data.appAuth.isdatateam) this.getGroup()
  43. this.setTabbar();
  44. this.partialRenewal();
  45. });
  46. },
  47. areaInput(e) {
  48. this.setData({
  49. deletereason: e.detail.value
  50. })
  51. },
  52. onCancel() {
  53. this.setData({
  54. deletereasonShow: false,
  55. })
  56. },
  57. deleteItem() {
  58. _Http.basic({
  59. id: 20221010164402,
  60. content: {
  61. deletereason: this.data.deletereason,
  62. sa_customersids: [this.data.sa_customersid],
  63. datastatus: '1'
  64. }
  65. }).then(res => {
  66. console.log("作废", res)
  67. wx.showToast({
  68. title: res.code == 1 ? '作废成功' : res.msg,
  69. icon: "none",
  70. mask: res.code == 1
  71. })
  72. if (res.code == 1) setTimeout(() => {
  73. wx.navigateBack()
  74. }, 300)
  75. })
  76. },
  77. setPreview(res) {
  78. /* 摘要信息 */
  79. let briefs = [{
  80. label: "医院编号",
  81. value: res.data.billno
  82. }, {
  83. label: "医院等级",
  84. value: res.data.grade
  85. }, {
  86. label: "医院类型",
  87. value: res.data.type
  88. }, {
  89. label: "开发阶段",
  90. value: res.data.stagename
  91. }, {
  92. label: "开发状态",
  93. value: getApp().globalData.Language.getMapText(res.data.status),
  94. style: `color:${this.data.sColors[res.data.status]}`
  95. }, {
  96. label: "成交状态",
  97. value: res.data.tradingstatus,
  98. style: `color:${this.data.sColors[res.data.tradingstatus]}`
  99. }];
  100. /* 基本信息 */
  101. let list1 = [{
  102. label: "医院编号",
  103. value: res.data.billno
  104. }, {
  105. label: "医院名称",
  106. value: res.data.enterprisename
  107. }, {
  108. label: "医院类型",
  109. value: res.data.type
  110. }, {
  111. label: "开发阶段",
  112. value: res.data.stagename
  113. }, {
  114. label: "医院等级",
  115. value: res.data.grade
  116. }, {
  117. label: "预估手术总量",
  118. value: res.data.totalop
  119. }, {
  120. label: "医院床位",
  121. value: res.data.bed
  122. }, {
  123. label: "手术间",
  124. value: res.data.room
  125. }, {
  126. label: "主机数量",
  127. value: res.data.host
  128. }, {
  129. label: "负责人",
  130. value: res.data.leader.length ? res.data.leader[0].name : ""
  131. }, {
  132. label: "营销区域",
  133. value: res.data.areaname
  134. }, {
  135. label: "所属部门",
  136. value: res.data.depname
  137. }, {
  138. label: "开发状态",
  139. value: getApp().globalData.Language.getMapText(res.data.status),
  140. style: `color:${this.data.sColors[res.data.status]}`
  141. }, {
  142. label: "成交状态",
  143. value: res.data.tradingstatus,
  144. style: `color:${this.data.sColors[res.data.tradingstatus]}`
  145. }];
  146. /* 系统信息 */
  147. let list2 = [{
  148. label: "创建人",
  149. value: res.data.createby
  150. }, {
  151. label: "创建时间",
  152. value: res.data.createdate
  153. }, {
  154. label: "最近编辑人",
  155. value: res.data.changeby
  156. }, {
  157. label: "最近编辑时间",
  158. value: res.data.changedate
  159. }, {
  160. label: "作废原因",
  161. value: res.data.deletereason
  162. }, {
  163. label: "转手次数",
  164. value: res.data.leader[0] ? res.data.leader[0].leadernum : 0
  165. }];
  166. this.setData({
  167. briefs,
  168. list1,
  169. list2
  170. });
  171. },
  172. //详情按钮回调
  173. tabbarOnClick({
  174. detail
  175. }) {
  176. let data = this.data.detail,
  177. that = this;
  178. switch (detail.label) {
  179. case "编辑":
  180. wx.navigateTo({
  181. url: `/prsx/hospital/insert?data=${JSON.stringify(data)}`,
  182. })
  183. break;
  184. case "作废":
  185. that.setData({
  186. deletereasonShow: true
  187. })
  188. break;
  189. case "更换负责人":
  190. wx.navigateTo({
  191. url: `/pages/group/select?data=${JSON.stringify({
  192. ownertable: "sa_customers",
  193. ownerid: this.data.sa_customersid,
  194. })}&radio=true&principal=true`,
  195. })
  196. break;
  197. case "查看重复":
  198. _Http.basic({
  199. "id": 20221208172002,
  200. "content": {
  201. ...data,
  202. pageSize: 999
  203. }
  204. }).then(res => {
  205. console.log("查看重复", res)
  206. if (res.code != '1') return wx.showToast({
  207. title: res.msg,
  208. icon: "none"
  209. });
  210. if (res.data.length == 0) return wx.showToast({
  211. title: getApp().globalData.Language.getMapText('未查询到重复数据'),
  212. icon: "none"
  213. });
  214. this.setData({
  215. repetitionList: res.data.map(v => {
  216. v.chars = v.chars.reduce((acc, item) => ({
  217. ...acc,
  218. ...item
  219. }), {});
  220. return v
  221. }),
  222. repetitionShow: true
  223. })
  224. })
  225. break;
  226. case "跟进":
  227. that.selectComponent("#Trace").toAdd()
  228. break;
  229. default:
  230. console.log(detail)
  231. break;
  232. }
  233. },
  234. /* 底部功能 */
  235. async setTabbar() {
  236. let detail = this.data.detail,
  237. isAdmin = this.data.isAdmin,
  238. isLeader = detail.leader.some(some => some.userid == wx.getStorageSync('userMsg').userid),
  239. editdataleader = isLeader ? 1 : 0,
  240. tabbarList = [],
  241. appAuth = this.data.appAuth,
  242. tabsList = [{
  243. label: "详细信息",
  244. icon: "icon-tabxiangxixinxi1"
  245. }, {
  246. label: "关联经销商",
  247. icon: "icon-jingxiaoshang",
  248. model: "#Dealer"
  249. }, {
  250. label: "科室",
  251. icon: "icon-keshi",
  252. model: "#Department"
  253. }, {
  254. label: "医生",
  255. icon: "icon-yisheng",
  256. model: "#Doctors"
  257. }, {
  258. label: "推荐产品",
  259. icon: "icon-tuijianchanpin",
  260. model: "#Product"
  261. }, {
  262. label: "地址管理",
  263. icon: "icon-tabdizhi",
  264. model: "#Address"
  265. }];
  266. if (!isLeader) {
  267. let res = await getApp().agentOrNot("sa_customers", this.data.sa_customersid),
  268. data = res.code == '1' ? res.data : {
  269. editable: 0,
  270. editdataleader: 0
  271. }
  272. if (appAuth.isdatateam) isLeader = this.selectComponent("#Group").data.editable == 1;
  273. if (!isLeader) isLeader = data.editable == 1;
  274. editdataleader = data.editdataleader;
  275. }
  276. if (appAuth.isdatafollowup) {
  277. tabsList.unshift({
  278. label: "跟进动态",
  279. icon: "icon-tabgenjinjilu",
  280. model: "#Trace"
  281. })
  282. if (detail.status != '已终止') tabbarList.unshift({
  283. icon: "color-genjin",
  284. label: "跟进"
  285. });
  286. }
  287. tabsList.push({
  288. label: "合同",
  289. icon: "icon-tabhetong",
  290. model: "#Contract"
  291. })
  292. tabsList = tabsList.concat([{
  293. label: "附件",
  294. icon: "icon-tabfujian1",
  295. model: "#Files"
  296. }, {
  297. label: "操作",
  298. icon: "icon-tabcaozuojilu1",
  299. model: "#Record"
  300. }])
  301. if (isLeader || isAdmin) {
  302. tabbarList.push({
  303. icon: "color-bianji",
  304. label: "编辑"
  305. })
  306. tabbarList.push({
  307. icon: "icon-shanchu",
  308. label: "作废"
  309. })
  310. }
  311. if (this.data.appAuth.options.find(v => v == 'viewRepetition')) tabbarList.push({
  312. icon: "icon-a-shouyejingangquhehuoren",
  313. label: "查看重复"
  314. });
  315. this.setData({
  316. tabbarList,
  317. isLeader,
  318. tabsList
  319. })
  320. },
  321. //tabs 切换
  322. tabsChange({
  323. detail
  324. }) {
  325. this.setData({
  326. tabsActive: detail
  327. });
  328. this.partialRenewal();
  329. },
  330. //局部数据更新 tabs
  331. partialRenewal(init = false) {
  332. try {
  333. let model = this.data.tabsList[this.data.tabsActive].model;
  334. if (model) {
  335. let Component = this.selectComponent(model),
  336. {
  337. total,
  338. pageNumber,
  339. pageTotal
  340. } = Component.data.content,
  341. id = model == "#Address" ? this.data.detail.sys_enterpriseid : this.data.detail.sa_customersid;
  342. if (model == "#Files") init = true;
  343. if (total == null || init) {
  344. Component.getList(id, init);
  345. } else if (pageNumber <= pageTotal) {
  346. Component.getList(id, false);
  347. }
  348. }
  349. } catch (error) {
  350. }
  351. },
  352. //更新标签
  353. getTags() {
  354. this.selectComponent("#Tags").getTags()
  355. },
  356. //更新团队成员
  357. getGroup() {
  358. this.selectComponent("#Group").getList().then(this.setTabbarList)
  359. },
  360. onReachBottom() {
  361. this.partialRenewal();
  362. },
  363. onUnload() {
  364. const page = getCurrentPages().find(v => v.__route__ == 'prsx/hospital/index');
  365. if (!page) return;
  366. let content = JSON.parse(JSON.stringify(page.data.content));
  367. content.pageSize = (content.pageNumber - 1) * content.pageSize;
  368. content.pageNumber = 1;
  369. _Http.basic({
  370. id: '20221012164402',
  371. content
  372. }).then(res => {
  373. console.log("更新列表", res);
  374. if (res.code == '1') {
  375. res.data = res.data.map(v => {
  376. v.totalstage = v.stages.length
  377. v.stage = v.stages.findIndex(s => s.stagename == v.stagename) + 1
  378. v.progress = v.stage / v.totalstage * 100;
  379. return v
  380. })
  381. page.setData({
  382. list: res.data,
  383. "content.total": res.total
  384. })
  385. }
  386. })
  387. }
  388. })