dashboard.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. function viewModel(RYXZ) {
  2. this.RYXZ = RYXZ
  3. //初始化数据
  4. this.init = function () {
  5. var that = this;
  6. //查询油表图
  7. $.ajax({
  8. url: '/Home/QueryNotFinishCount',
  9. method: 'get',
  10. success: function (data) {
  11. $.each(data, function (i, n) {
  12. var val = 0;
  13. if (data[i].数量 != undefined) {
  14. val = data[i].数量;
  15. }
  16. that.gauge('container' + i, data[i].类型, 100, val);
  17. });
  18. }
  19. });
  20. //加载公告
  21. $.post("/Notice/GetHome", function (data) {
  22. for (var i in data) {
  23. var val = data[i].发布时间;
  24. if (val < 1) {
  25. data[i].发布时间 = parseInt(val * 60) + "分钟前";
  26. } else if (val < 24) {
  27. data[i].发布时间 = val + "小时前";
  28. } else if (48 > val > 24) {
  29. data[i].发布时间 = "昨天";
  30. } else {
  31. data[i].发布时间 = parseInt(val / 24) + '天' + '前';
  32. }
  33. $("#Newnoty").append("<p><a href='#' onclick=\"MessageDeatil('" + data[i].ID + "')\" >" + data[i].标题 + "</a><a style='float:right'> " + data[i].发布时间 + "</a></p>");
  34. }
  35. })
  36. //查询各渠道的数量
  37. $.ajax({
  38. url: '/Home/QueryCompanyProblemCount',
  39. method: 'get',
  40. success: function (data) {
  41. var names = [];
  42. var series = [];
  43. //添加bug
  44. var serieBug = {};
  45. serieBug.name = 'BUG';
  46. serieBug.data = [];
  47. //添加任务
  48. var serieTask = {};
  49. serieTask.name = '任务';
  50. serieTask.data = [];
  51. //需求
  52. var serieReq = {};
  53. serieReq.name = '需求';
  54. serieReq.data = [];
  55. //咨询
  56. var serieAsk = {};
  57. serieAsk.name = '咨询';
  58. serieAsk.data = [];
  59. //循环读序列
  60. $.each(data, function (i, n) {
  61. names.push(data[i].名称);
  62. serieBug.data.push(data[i].BUG);
  63. serieTask.data.push(data[i].任务);
  64. serieReq.data.push(data[i].需求);
  65. serieAsk.data.push(data[i].咨询);
  66. });
  67. series.push(serieBug);
  68. series.push(serieTask);
  69. series.push(serieReq);
  70. series.push(serieAsk);
  71. that.column('container-column', 'bar', '所有还未处理的问题', names, series);
  72. }
  73. });
  74. //查询问题停留环节
  75. $.ajax({
  76. url: '/Home/QueryAllProblemStopWorkFlow',
  77. method: 'post',
  78. success: function (data) {
  79. var lineCategories = [];
  80. var lineSeries = [];
  81. var lineSerie = {};
  82. lineSerie.data = [];
  83. $.each(data, function (i, n) {
  84. var val = 0;
  85. if (data[i].名称 != undefined) {
  86. lineCategories.push(data[i].名称);
  87. }
  88. lineSerie.name = '停留数量';
  89. lineSerie.data.push(data[i].数量);
  90. });
  91. //添加到序列中
  92. lineSeries.push(lineSerie);
  93. //设置
  94. model.column('problemStop', 'column', '未处理问题延迟所在环节', lineCategories, lineSeries);
  95. }
  96. });
  97. //与我相关的问题
  98. $('#dgMyProlem').datagrid({
  99. fit: true,
  100. border: false,
  101. columns: [[
  102. { field: '编号', title: '编号', width: 60, align: 'center' },
  103. {
  104. field: '问题性质', title: '性质', width: 60, align: 'center', formatter: function (val, row, index) {
  105. switch (val) {
  106. case 1:
  107. return "<i class='fa fa-bug' title='Bug' style='color:red'>Bug</i>";
  108. case 2:
  109. return "<i class='fa fa-commenting-o' title='咨询'>咨询</i>";
  110. case 3:
  111. return "<i class='fa fa-dropbox' title='需求' style='color:#3279b6'>需求</i>";
  112. case 4:
  113. return "<i class='fa fa-history' title='任务'>任务</i>";
  114. default:
  115. break;
  116. }
  117. }
  118. },
  119. { field: '当前环节', title: '当前环节', width: 90, halign: 'center' },
  120. {
  121. field: '问题标题', title: '【问题标题】', width: 351, halign: 'center'
  122. }
  123. ]],
  124. singleSelect: true,
  125. striped: true,
  126. url: '/Home/QueryMyProblemList',
  127. onDblClickRow: function (rowIndex, rowData) {
  128. that.checkproblem();
  129. }
  130. });
  131. //常见问题
  132. $('#dgNorProlems').datagrid({
  133. fit: true,
  134. border: false,
  135. singleSelect: true,
  136. striped: true,
  137. columns: [[
  138. { field: '编号', title: '编号', width: 60, align: 'center' },
  139. { field: '问题标题', title: '【问题标题】', width: 361, halign: 'center' },
  140. { field: '版本号', title: '版本号', width: 60 },
  141. { field: '登记日期', title: '登记日期', width: 80 }
  142. ]],
  143. url: '/Home/QueryOftenProblemList'
  144. })
  145. };
  146. //加载油表图
  147. //id:元素id,text:标题,maxvalu:最大值,value:当前值
  148. this.gauge = function (id, text, maxval, value) {
  149. //油表图基本信息
  150. var gaugeOptions = {
  151. chart: {
  152. type: 'solidgauge'
  153. },
  154. title: {
  155. text: text
  156. },
  157. pane: {
  158. center: ['50%', '85%'],
  159. size: '140%',
  160. startAngle: -90,
  161. endAngle: 90,
  162. background: {
  163. backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#EEE',
  164. innerRadius: '60%',
  165. outerRadius: '100%',
  166. shape: 'arc'
  167. }
  168. },
  169. tooltip: {
  170. enabled: false
  171. },
  172. credits: {
  173. enabled: false
  174. },
  175. // the value axis
  176. yAxis: {
  177. min: 0,
  178. max: maxval,
  179. title: {
  180. text: text
  181. },
  182. stops: [
  183. [0.1, '#55BF3B'], // green
  184. [0.5, '#DDDF0D'], // yellow
  185. [0.9, '#DF5353'] // red
  186. ],
  187. lineWidth: 0,
  188. minorTickInterval: null,
  189. tickAmount: 2,
  190. title: {
  191. y: -70
  192. },
  193. labels: {
  194. y: 16
  195. }
  196. },
  197. plotOptions: {
  198. solidgauge: {
  199. dataLabels: {
  200. y: 5,
  201. borderWidth: 0,
  202. useHTML: true
  203. }
  204. }
  205. },
  206. series: [{
  207. name: 'gauge',
  208. data: [value],
  209. dataLabels: {
  210. format: '<div style="text-align:center"><span style="font-size:20px;color:' +
  211. ((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y}</span><br/>' +
  212. '<span style="font-size:13px;color:Green">待处理</span></div>'
  213. }
  214. }]
  215. };
  216. //设置图表
  217. Highcharts.chart(id, gaugeOptions);
  218. };
  219. //显示柱状堆积图id:元素id,text:标题,type:bar/column
  220. /*categories:渠道列表['中联西安公司', '沈阳技术服务中心'...]
  221. series:值,[{name: '需求', data: [5, 3, 4, 7, 2, 5, 3, 4, 7, 2]}, { name: 'Bug', data: [2, 2, 3, 2, 1, 5, 3, 4, 7, 2]}]*/
  222. this.column = function (id, type, text, categories, series) {
  223. var columnJson = {
  224. chart: {
  225. type: type
  226. },
  227. title: {
  228. text: text
  229. },
  230. credits: {
  231. enabled: false
  232. },
  233. xAxis: {
  234. categories: categories
  235. },
  236. yAxis: {
  237. min: 0,
  238. stackLabels: {
  239. enabled: true
  240. }
  241. },
  242. legend: {
  243. reversed: true
  244. },
  245. tooltip: {
  246. headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
  247. pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
  248. '<td style="padding:0"><b>{point.y:1f} 个</b></td></tr>',
  249. footerFormat: '</table>',
  250. shared: true,
  251. useHTML: true
  252. },
  253. plotOptions: {
  254. series: {
  255. stacking: 'normal'
  256. },
  257. column: {
  258. colorByPoint: true
  259. }
  260. },
  261. series: series
  262. }
  263. //设置到元素上
  264. Highcharts.chart(id, columnJson);
  265. };
  266. //线性图
  267. //id:元素id,text:标题,categories:人员['张三', '李四'...],series:,[{name: '项目问题', data: [5, 3, 4, 7, 2, 5, 3, 4, 7, 2]}, { name: '产品问题', data: [2, 2, 3, 2, 1, 5, 3, 4, 7, 2]}]*/
  268. this.line = function (id, text, subtitle, categories, series) {
  269. var lineJson = {
  270. chart: {
  271. type: 'line'
  272. },
  273. title: {
  274. text: text
  275. },
  276. subtitle: {
  277. text: subtitle
  278. },
  279. credits: {
  280. enabled: false
  281. },
  282. xAxis: {
  283. categories: categories
  284. },
  285. plotOptions: {
  286. line: {
  287. dataLabels: {
  288. enabled: true
  289. },
  290. enableMouseTracking: false
  291. }
  292. },
  293. series: series
  294. };
  295. //设置到元素上
  296. Highcharts.chart(id, lineJson);
  297. };
  298. //区域图
  299. //id:元素id,text:标题,categories:人员['张三', '李四'...],series:,[{name: '项目问题', data: [5, 3, 4, 7, 2, 5, 3, 4, 7, 2]}, { name: '产品问题', data: [2, 2, 3, 2, 1, 5, 3, 4, 7, 2]}]*/
  300. this.area = function (id, text, categories, series) {
  301. var json = {
  302. chart: {
  303. type: 'areaspline'
  304. },
  305. title: {
  306. text: text
  307. },
  308. legend: {
  309. layout: 'vertical',
  310. align: 'left',
  311. verticalAlign: 'top',
  312. x: 150,
  313. y: 100,
  314. floating: true,
  315. borderWidth: 1,
  316. backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
  317. },
  318. xAxis: {
  319. categories: categories
  320. },
  321. yAxis: {
  322. title: {
  323. text: ''
  324. }
  325. },
  326. tooltip: {
  327. shared: true
  328. },
  329. credits: {
  330. enabled: false
  331. },
  332. plotOptions: {
  333. areaspline: {
  334. fillOpacity: 0.5
  335. }
  336. },
  337. series: series
  338. };
  339. //设置到元素上
  340. Highcharts.chart(id, json);
  341. }
  342. //查看问题弹窗
  343. this.checkproblem = function () {
  344. var that=this
  345. var WT = $('#dgMyProlem').datagrid("getSelected");
  346. if (WT == null) {
  347. top.ZLPMS.Msg("请选择一行数据!");
  348. }
  349. else {
  350. top.ZLPMS.OpenNewWindow("查看问题", "/Problem/CheckProblemWindow/" + WT["ID"], '880px', '600px', function () {
  351. that.DealProblem(0, 0, WT["ID"]);
  352. });
  353. }
  354. }
  355. //处理问题
  356. this.DealProblem = function (showAtt, IsSupport, ProblemId) {
  357. var that = this
  358. //是否为技术支持处理
  359. IsSupport = IsSupport || 0;
  360. //受理问题
  361. var receiveProblem = function (title,HJID) {
  362. var index = top.ZLPMS.Loading3(2);
  363. //受理问题
  364. $.ajax({
  365. url: '/Support/ReceiveProblem',
  366. data: { id: ProblemId },
  367. method: 'post',
  368. success: function (data) {
  369. top.ZLPMS.UnLoading(index);
  370. var url = "/Problem/ProductionPdeal?id=" + ProblemId + "&showAtt=" + showAtt + '&workflowid=' + HJID + '&IsSupport=' + IsSupport;
  371. //成功后调用
  372. if (data.code == 200) {
  373. top.ZLPMS.OpenNewWindow("处理问题:" + title, url, '1000px', '640px', function () {
  374. //回调用刷新(只有确定后才刷新)
  375. });
  376. } else {//显示具体原因,并提示是否强制处理
  377. top.ZLPMS.Confirm('该问题已被他人受理,您确定要继续处理吗?', 3, function (idx) {
  378. top.ZLPMS.CloseWindow(idx);
  379. top.ZLPMS.OpenNewWindow("处理问题", url, '1000px', '640px');
  380. })
  381. }
  382. }
  383. });
  384. };
  385. $.post('/Problem/GetProblemById/' + ProblemId, function (data) {
  386. var row = data[0];
  387. if (row) {
  388. /*已关闭的问题,已解决的问题,已受理的问题, 不需要处理*/
  389. if (row.是否终止 == 1) {
  390. top.ZLPMS.Msg('已终止的问题不需要再处理!');
  391. return;
  392. }
  393. if (row.是否解决 == 1) {
  394. top.ZLPMS.Msg('已解决的问题不需要再处理!');
  395. return;
  396. }
  397. if (row.环节ID > 3 && that.RYXZ != '1') {
  398. top.ZLPMS.Msg('非本部人员不能处理技术支持与研发处理环节问题,仅能查阅!');
  399. return;
  400. }
  401. if (row.环节ID == 3 && (that.RYXZ == '3' || that.RYXZ == '4' || that.RYXZ == '5')) {//客户,机构管理员,卫计委人员无法处理项目问题
  402. top.ZLPMS.Msg('客户,机构管理员,卫计委人员无法处理项目问题,仅能查阅!');
  403. return;
  404. }
  405. //打开处理窗口
  406. receiveProblem(row.编号, row.环节ID);
  407. } else {//提醒用户没有选择问题记录
  408. top.ZLPMS.Msg('没有选择需要处理的问题记录,请选择后再处理!');
  409. }
  410. })
  411. }
  412. }