itdmGongdanMasterList.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. <template>
  2. <div class="container" style="height:650px;">
  3. <div class="table-page-search-wrapper">
  4. <a-form layout="inline" @keyup.enter.native="getHjlist">
  5. <a-row :gutter="24">
  6. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  7. <a-form-item label="委托编号">
  8. <a-input placeholder="请输入委托编号" v-model="tasks.queryParam.weituoNo"></a-input>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  12. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  13. <a-button type="primary" @click="getHjlist" icon="search">查询</a-button>
  14. <!-- <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">提交</a-button> -->
  15. </span>
  16. </a-col>
  17. </a-row>
  18. </a-form>
  19. </div>
  20. <div ref="gantt" :tasks="tasks" style="height:600px;"></div>
  21. </div>
  22. </template>
  23. <script>
  24. import {gantt} from 'dhtmlx-gantt';
  25. import { notification } from 'ant-design-vue';
  26. import {getDeviceList, getXmjlList, getManagerList, getCgqList, saveProject, ajaxGetDictItems, saveProjectJl, delProjectJl} from '@/api/api'
  27. import store from '@/store'
  28. export default {
  29. name: 'gantt',
  30. data () {
  31. return {
  32. tasks: {
  33. data: [
  34. ],
  35. collections: {
  36. staff:[],
  37. staff2:[],
  38. worker:[],
  39. chuanganqi:[],
  40. chuanganqi2:[],
  41. testTypeOptions: [],
  42. },
  43. queryParam:{
  44. weituoNo: undefined
  45. },
  46. },
  47. }
  48. },
  49. created() {
  50. // 清空数据
  51. gantt.clearAll();
  52. // 获取当前登录用户的信息
  53. console.log(store.getters.userInfo)
  54. this.getDevicelist();
  55. this.getCgqlist();
  56. this.getManagerList();
  57. this.initDictConfig();
  58. // this.initData()
  59. },
  60. beforeDestroy() {
  61. gantt.clearAll();
  62. },
  63. mounted() {
  64. // 启用动态加载
  65. gantt.config.branch_loading = true
  66. //日期格式化
  67. gantt.config.xml_date = "%Y-%m-%d";
  68. gantt.config.date_format = "%Y-%m-%d";
  69. gantt.config.order_branch = true;
  70. gantt.config.order_branch_free = true;
  71. //左侧是否自适应
  72. gantt.config.autofit = true;
  73. gantt.config.drag_links = false;//连线
  74. gantt.config.readonly = false; //只读
  75. gantt.config.date_scale = "%m月%d日"; //右侧显示列名
  76. gantt.config.layout = {//拖拽布局
  77. css: "gantt_container",
  78. rows: [
  79. {
  80. cols: [
  81. { view: "grid", id: "grid", scrollX: "scrollHor", scrollY: "scrollVer" },
  82. { resizer: true, width: 1 },
  83. { view: "timeline", id: "timeline", scrollX: "scrollHor", scrollY: "scrollVer" },
  84. { view: "scrollbar", scroll: "y", id: "scrollVer" }
  85. ]
  86. },
  87. { view: "scrollbar", scroll: "x", id: "scrollHor", height: 20 }
  88. ],
  89. };
  90. // 重置布局
  91. gantt.resetLayout();
  92. gantt.config.start_on_monday = true;
  93. gantt.config.work_time = false;
  94. gantt.config.fit_tasks = true; //自动调整图表坐标轴区间用于适配task的长度
  95. // 甘特图汉化
  96. gantt.locale = {
  97. date: {
  98. month_full: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
  99. month_short: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
  100. day_full: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
  101. day_short: ["日", "一", "二", "三", "四", "五", "六"]
  102. },
  103. labels: {
  104. dhx_cal_today_button: "今天",
  105. day_tab: "日",
  106. week_tab: "周",
  107. month_tab: "月",
  108. new_event: "新建日程",
  109. icon_save: "保存",
  110. icon_cancel: "关闭",
  111. icon_details: "详细",
  112. icon_edit: "编辑",
  113. icon_delete: "删除",
  114. confirm_closing: "请确认是否撤销修改!", //Your changes will be lost, are your sure?
  115. confirm_deleting: "是否删除计划?",
  116. section_description: "描述:",
  117. section_time: "时间范围:",
  118. section_type: "类型:",
  119. section_text: "计划名称:",
  120. section_neirong: "内容:",
  121. section_test: "测试:",
  122. section_projectClass: "项目类型:",
  123. taskProjectType_0: "项目任务",
  124. taskProjectType_1: "普通任务",
  125. section_head: "项目经理:",
  126. section_device: "试验设备:",
  127. section_sensor: "传感器:",
  128. section_reportNo: "报告编号:",
  129. section_shiiyanType: "试验类型:",
  130. section_worker: "试验员:",
  131. section_yangpinCount: "样品数量:",
  132. section_priority: '优先级:',
  133. status: '任务状态',
  134. status_0: "未确认",
  135. status_1: "已确认",
  136. status_2: "完成",
  137. status_3: "已延期",
  138. status_4: "搁置中",
  139. section_template: 'Details',
  140. /* grid columns */
  141. column_text: "计划名称",
  142. column_sampleName: "样品名称",
  143. column_testItems: "检测项目",
  144. column_start_date: "开始时间",
  145. column_duration: "持续时间",
  146. column_lastTime: "持续时间",
  147. column_add: "",
  148. column_priority: "难度",
  149. /* link confirmation */
  150. link: "关联",
  151. confirm_link_deleting: "将被删除",
  152. link_start: " (开始)",
  153. link_end: " (结束)",
  154. type_task: "任务",
  155. type_project: "项目",
  156. type_milestone: "里程碑",
  157. minutes: "分钟",
  158. hours: "小时",
  159. days: "天",
  160. weeks: "周",
  161. months: "月",
  162. years: "年"
  163. }
  164. };
  165. // 删除左侧列表表头的add按钮
  166. gantt.templates.grid_header_class = function(columnName, column){
  167. if (columnName == 'add') {
  168. return "noShow";
  169. }
  170. };
  171. // 左侧列表内容
  172. gantt.config.columns = [
  173. // { name: "text", min_width:100,max_width:200, label:"任务", align: "left",resize: true, tree: true },
  174. { name: "testItems", label: "检测项目", width: 130, resize: true, align: "left",resize: true, tree: true },
  175. { name: "sampleName", label: "样品名称", width: 90, resize: true, align: "center" },
  176. { name: "start_date", label: "开始时间", width: 90, resize: true, align: "center" },
  177. { name: "end_date", label: "结束时间", width: 90, resize: true, align: "center" },
  178. { name: "statusC", label: "状态", width: 60, resize: true, align: "center" },
  179. { name: "add", label:"", width: 30 }
  180. ];
  181. // 更改左侧显示的结束日期时间
  182. gantt.templates.task_end_date = function(date){
  183. return gantt.templates.task_date(new Date(date.valueOf() - 1));
  184. };
  185. var gridDateToStr = gantt.date.date_to_str("%Y-%m-%d");
  186. gantt.templates.grid_date_format = function(date, column){
  187. if(column === "end_date"){
  188. return gridDateToStr(new Date(date.valueOf() - 1));
  189. }else{
  190. return gridDateToStr(date);
  191. }
  192. }
  193. // 右侧项目展示
  194. gantt.templates.task_text = function (start, end, task) {
  195. console.log("右侧展示",task)
  196. if (task.parent == 0) {
  197. return task.pm + ", " + task.deviceName;
  198. } else {
  199. return task.worker + ", " + task.deviceName;
  200. }
  201. // return task.worker + ", " + task.deviceName;
  202. };
  203. // 灯箱多选框
  204. gantt.form_blocks["multiselect"] = {
  205. render: function (sns) {
  206. var height = (sns.height || "23") + "px";
  207. var html = "<div class='gantt_cal_ltext gantt_cal_chosen gantt_cal_multiselect'"+
  208. "style='height:"+ height + ";'><select data-placeholder='...'"+
  209. "class='chosen-select' multiple>";
  210. if (sns.options) {
  211. for (var i = 0; i < sns.options.length; i++) {
  212. if(sns.unassigned_value !== undefined && sns.options[i].key==sns.unassigned_value){
  213. continue;
  214. }
  215. html+="<option value='" +sns.options[i].key+ "'>"+sns.options[i].label+"</option>";
  216. }}
  217. html += "</select></div>";
  218. return html;},
  219. set_value: function (node, value, ev, sns) {
  220. node.style.overflow = "visible";
  221. node.parentNode.style.overflow = "visible";
  222. node.style.display = "inline-block";
  223. var select = $(node.firstChild);
  224. if (value) {
  225. value = (value + "").split(",");
  226. select.val(value);
  227. }
  228. else {
  229. select.val([]);
  230. }
  231. select.chosen();
  232. if(sns.onchange){
  233. select.change(function(){
  234. sns.onchange.call(this);
  235. })
  236. }
  237. select.trigger('chosen:updated');
  238. select.trigger("change");},
  239. get_value: function (node, ev) {
  240. var value = $(node.firstChild).val();
  241. //value = value ? value.join(",") : null
  242. return value;},
  243. focus: function (node) {
  244. $(node.firstChild).focus();
  245. }};
  246. // 单击获取当前行信息
  247. // gantt.attachEvent("onTaskRowClick", function (id, e){
  248. // let that = this
  249. // console.log("单击当前行",id,e)
  250. // gantt.getTask(id);
  251. // //any custom logic here
  252. // return true;
  253. // });
  254. // 给灯箱赋默认值(将父任务的参数赋给灯箱)
  255. gantt.attachEvent("onTaskCreated", function(task){
  256. console.log("给灯箱赋默认值",task,gantt.getTask(task.parent))
  257. // 灯箱部分
  258. task.shebeiId = gantt.getTask(task.parent).shebeiId
  259. // task.reportNo = gantt.getTask(task.parent).reportNo
  260. task.chuanganqiArray = gantt.getTask(task.parent).chuanganqiArray
  261. // 灯箱虽不展示,但也要赋值
  262. task.deviceName = gantt.getTask(task.parent).deviceName
  263. task.yangpinId = gantt.getTask(task.parent).yangpinId
  264. task.sampleName = gantt.getTask(task.parent).sampleName
  265. task.shijiStartDate = gantt.getTask(task.parent).shijiStartDate
  266. task.testItems = gantt.getTask(task.parent).testItems
  267. task.testItemsId = gantt.getTask(task.parent).testItemsId
  268. task.testPlanId = gantt.getTask(task.parent).testPlanId
  269. task.weituoId = gantt.getTask(task.parent).weituoId
  270. task.weituoNo = gantt.getTask(task.parent).weituoNo
  271. console.log("第二个",task)
  272. return true;
  273. });
  274. //弹出层(灯箱)
  275. // gantt.config.lightbox.sections = [
  276. // ];
  277. // 根据判断不同级别任务弹不同的灯框(并展示不同的按钮)
  278. var full_lightbox =[
  279. {
  280. name: "time", height: 40, map_to: "auto", type: "duration",
  281. time_format: ["%Y", "%m", "%d"],
  282. },
  283. // { name: "reportNo", height: 30, map_to: "reportNo", type: "textarea", },
  284. { name: "device", height: 30, map_to: "shebeiId", type: "select", options: gantt.serverList('staff2',[]), },
  285. { name: "sensor", height: 30, map_to: "chuanganqiArray", type: "multiselect", options: gantt.serverList('chuanganqi2',[]), },
  286. { name: "shiiyanType", height: 30, map_to: "shiiyanTypeArray", type: "multiselect", options: gantt.serverList('testTypeOptions',[]), },
  287. { name: "worker", height: 30, map_to: "worker", type: "select", options: gantt.serverList('worker',[]), },
  288. { name: "yangpinCount", height: 30, map_to: "yangpinCount", type: "textarea", width: 60 },
  289. { name: "neirong", height: 45, map_to: "neirong", type: "textarea", focus: true, width: "*", },
  290. ];
  291. var restricted_lightbox = [
  292. {
  293. name: "time", height: 40, map_to: "auto", type: "duration",
  294. time_format: ["%Y", "%m", "%d"],
  295. },
  296. { name: "reportNo", height: 30, map_to: "reportNo", type: "textarea" },
  297. { name: "device", height: 30, map_to: "shebeiId", type: "select", options: gantt.serverList('staff',[]), },
  298. { name: "sensor", height: 30, map_to: "chuanganqiArray", type: "multiselect", options: gantt.serverList('chuanganqi',[]), },
  299. ];
  300. gantt.attachEvent("onBeforeLightbox", function(task_id) {
  301. gantt.resetLightbox();
  302. var task = gantt.getTask(task_id);
  303. // console.log("重置灯箱",task)
  304. if (task.$level == 0){
  305. gantt.config.lightbox.sections = restricted_lightbox;
  306. gantt.config.buttons_left = ["gantt_cancel_btn"];
  307. gantt.config.buttons_right = [];
  308. } else {
  309. gantt.config.lightbox.sections = full_lightbox;
  310. gantt.config.buttons_left = ["gantt_save_btn", "gantt_cancel_btn"];
  311. gantt.config.buttons_right = ["gantt_delete_btn"];
  312. };
  313. return true;
  314. });
  315. // 展示灯箱里的删除按钮
  316. // gantt.config.buttons_right = ["gantt_delete_btn"];
  317. // 点击灯箱的保存按钮触发
  318. let that = this
  319. gantt.attachEvent("onLightboxSave", function(id, task, is_new){
  320. console.log(id, task, is_new)
  321. let y = task.start_date.getFullYear()
  322. let m = task.start_date.getMonth() + 1
  323. m = m < 10 ? ('0' + m) : m
  324. let d = task.start_date.getDate()
  325. d = d < 10 ? ('0' + d) : d
  326. task.jihuaStartDate = y + '-' + m + '-' + d ;
  327. // task.jihuaStartDate = task.start_date
  328. task.lastTime = task.duration
  329. console.log("提交",task)
  330. saveProjectJl(task).then((res) => {
  331. console.log("提交返回",task,res)
  332. gantt.clearAll();
  333. gantt.init(that.$refs.gantt);
  334. gantt.parse(that.tasks);
  335. // that.getHjlist(that.tasks.queryParam)
  336. })
  337. return true;
  338. })
  339. // 点击灯箱删除按钮触发
  340. gantt.attachEvent("onLightboxDelete", function(id){
  341. const task = gantt.getTask(id);
  342. console.log(task)
  343. if (task.statusC == "不可修改"){
  344. // alert("该项已进行,不可修改");
  345. notification.open({
  346. message: '注意',
  347. description: "该项已进行,不可修改",
  348. });
  349. gantt.hideLightbox();
  350. return false;
  351. }else{
  352. return true;
  353. }
  354. })
  355. // 在删除任务之前触发
  356. gantt.attachEvent("onBeforeTaskDelete", function(id,item){
  357. var select={id:id}
  358. delProjectJl(select).then((res) => {
  359. console.log("删除",res)
  360. if (res.success) {
  361. return true;
  362. } else {
  363. return false;
  364. }
  365. })
  366. //any custom logic here
  367. // return true;
  368. });
  369. // 隐藏某行的添加按钮
  370. gantt.templates.grid_row_class = function( start, end, task ){
  371. // console.log("隐藏",task)
  372. if ( task.$level > 0 ){
  373. return "nested_task"
  374. }
  375. return "";
  376. };
  377. // // 自定义弹框
  378. // let that = this
  379. // gantt.attachEvent("onTaskDblClick", function (id, e){
  380. // console.log(111,id, e);
  381. // that.id = id
  382. // gantt.getTask(that.id);
  383. // console.log("双击获取当前行信息",gantt.getTask(that.id),gantt.getTask(that.id).parent);
  384. // if (gantt.getTask(that.id).parent == 0) {
  385. // 单击获取当前行信息
  386. // gantt.attachEvent("onTaskRowClick", function (id, e){
  387. // let that = this
  388. // console.log("单击当前行",id,e)
  389. // gantt.getTask(id);
  390. // //any custom logic here
  391. // return true;
  392. // });
  393. // 给灯箱赋默认值(将父任务的参数赋给灯箱)
  394. gantt.attachEvent("onTaskCreated", function(task){
  395. console.log("给灯箱赋默认值",task,gantt.getTask(task.parent))
  396. if (task.parent == undefined) {
  397. return false;
  398. } else {
  399. // 灯箱部分
  400. task.shebeiId = gantt.getTask(task.parent).shebeiId
  401. // task.reportNo = gantt.getTask(task.parent).reportNo
  402. task.chuanganqiArray = gantt.getTask(task.parent).chuanganqiArray
  403. // 灯箱虽不展示,但也要赋值
  404. task.deviceName = gantt.getTask(task.parent).deviceName
  405. task.yangpinId = gantt.getTask(task.parent).yangpinId
  406. task.sampleName = gantt.getTask(task.parent).sampleName
  407. task.shijiStartDate = gantt.getTask(task.parent).shijiStartDate
  408. task.testItems = gantt.getTask(task.parent).testItems
  409. task.testItemsId = gantt.getTask(task.parent).testItemsId
  410. task.testPlanId = gantt.getTask(task.parent).testPlanId
  411. task.weituoId = gantt.getTask(task.parent).weituoId
  412. task.weituoNo = gantt.getTask(task.parent).weituoNo
  413. console.log("第二个",task)
  414. return true;
  415. }
  416. });
  417. //弹出层(灯箱)
  418. // gantt.config.lightbox.sections = [
  419. // ];
  420. // 根据判断不同级别任务弹不同的灯框(并展示不同的按钮)
  421. var full_lightbox =[
  422. {
  423. name: "time", height: 40, map_to: "auto", type: "duration",
  424. time_format: ["%Y", "%m", "%d"],
  425. },
  426. // { name: "reportNo", height: 30, map_to: "reportNo", type: "textarea", },
  427. { name: "device", height: 30, map_to: "shebeiId", type: "select", options: gantt.serverList('staff2',[]), },
  428. { name: "sensor", height: 30, map_to: "chuanganqiArray", type: "multiselect", options: gantt.serverList('chuanganqi2',[]), },
  429. { name: "shiiyanType", height: 30, map_to: "shiiyanTypeArray", type: "multiselect", options: gantt.serverList('testTypeOptions',[]), },
  430. { name: "worker", height: 30, map_to: "worker", type: "select", options: gantt.serverList('worker',[]), },
  431. { name: "yangpinCount", height: 30, map_to: "yangpinCount", type: "textarea", width: 60 },
  432. { name: "neirong", height: 45, map_to: "neirong", type: "textarea", focus: true, width: "*", },
  433. ];
  434. var restricted_lightbox = [
  435. {
  436. name: "time", height: 40, map_to: "auto", type: "duration",
  437. time_format: ["%Y", "%m", "%d"],
  438. },
  439. { name: "reportNo", height: 30, map_to: "reportNo", type: "textarea" },
  440. { name: "device", height: 30, map_to: "shebeiId", type: "select", options: gantt.serverList('staff',[]), },
  441. { name: "sensor", height: 30, map_to: "chuanganqiArray", type: "multiselect", options: gantt.serverList('chuanganqi',[]), },
  442. ];
  443. gantt.attachEvent("onBeforeLightbox", function(task_id) {
  444. gantt.resetLightbox();
  445. var task = gantt.getTask(task_id);
  446. // console.log("重置灯箱",task)
  447. if (task.$level == 0){
  448. gantt.config.lightbox.sections = restricted_lightbox;
  449. gantt.config.buttons_left = ["gantt_cancel_btn"];
  450. gantt.config.buttons_right = [];
  451. } else {
  452. gantt.config.lightbox.sections = full_lightbox;
  453. gantt.config.buttons_left = ["gantt_save_btn", "gantt_cancel_btn"];
  454. gantt.config.buttons_right = ["gantt_delete_btn"];
  455. };
  456. return true;
  457. });
  458. // 展示灯箱里的删除按钮
  459. // gantt.config.buttons_right = ["gantt_delete_btn"];
  460. // 点击灯箱的保存按钮触发
  461. let that = this
  462. gantt.attachEvent("onLightboxSave", function(id, task, is_new){
  463. console.log(id, task, is_new)
  464. let y = task.start_date.getFullYear()
  465. let m = task.start_date.getMonth() + 1
  466. m = m < 10 ? ('0' + m) : m
  467. let d = task.start_date.getDate()
  468. d = d < 10 ? ('0' + d) : d
  469. task.jihuaStartDate = y + '-' + m + '-' + d ;
  470. // task.jihuaStartDate = task.start_date
  471. task.lastTime = task.duration
  472. console.log("提交",task)
  473. saveProjectJl(task).then((res) => {
  474. console.log("提交返回",task,res)
  475. gantt.init(that.$refs.gantt);
  476. gantt.parse(that.tasks);
  477. // that.getHjlist(that.tasks.queryParam)
  478. })
  479. return true;
  480. })
  481. // 点击灯箱删除按钮触发
  482. gantt.attachEvent("onLightboxDelete", function(id){
  483. const task = gantt.getTask(id);
  484. console.log(task)
  485. if (task.statusC == "不可修改"){
  486. // alert("该项已进行,不可修改");
  487. notification.open({
  488. message: '注意',
  489. description: "该项已进行,不可修改",
  490. });
  491. gantt.hideLightbox();
  492. return false;
  493. }else{
  494. return true;
  495. }
  496. })
  497. // 在删除任务之前触发
  498. gantt.attachEvent("onBeforeTaskDelete", function(id,item){
  499. var select={id:id}
  500. delProjectJl(select).then((res) => {
  501. console.log("删除",res)
  502. if (res.success) {
  503. return true;
  504. } else {
  505. return false;
  506. }
  507. })
  508. //any custom logic here
  509. // return true;
  510. });
  511. // 隐藏某行的添加按钮
  512. gantt.templates.grid_row_class = function( start, end, task ){
  513. // console.log("隐藏",task)
  514. if ( task.$level > 0 ){
  515. return "nested_task"
  516. }
  517. return "";
  518. };
  519. // // 自定义弹框
  520. // let that = this
  521. // gantt.attachEvent("onTaskDblClick", function (id, e){
  522. // console.log(111,id, e);
  523. // that.id = id
  524. // gantt.getTask(that.id);
  525. // console.log("双击获取当前行信息",gantt.getTask(that.id),gantt.getTask(that.id).parent);
  526. // if (gantt.getTask(that.id).parent == 0) {
  527. // } else {
  528. // }
  529. // return true;
  530. // });
  531. gantt.init(this.$refs.gantt);
  532. // gantt.parse(this.tasks);
  533. },
  534. methods: {
  535. // 获取设备下拉列表
  536. getDevicelist(){
  537. getDeviceList().then((res) => {
  538. this.tasks.collections.staff = res.map(response =>{
  539. return {
  540. value: response.id,
  541. label: response.deviceName
  542. }
  543. })
  544. this.tasks.collections.staff2 = this.tasks.collections.staff
  545. //this.initData()
  546. })
  547. },
  548. // 获取传感器下拉列表
  549. getCgqlist(){
  550. getCgqList().then((res) => {
  551. this.tasks.collections.chuanganqi = res.map(response =>{
  552. return {
  553. key: response.id,
  554. value: response.id,
  555. label: response.xuliehao
  556. }
  557. })
  558. this.tasks.collections.chuanganqi2 = this.tasks.collections.chuanganqi
  559. // this.initData()
  560. })
  561. },
  562. // 获取项目经理下拉列表
  563. getManagerList(){
  564. var query ={
  565. position: "项目经理"
  566. }
  567. getManagerList(query).then((res) => {
  568. this.tasks.collections.worker = res.map(response =>{
  569. return {
  570. key: response.name,
  571. value: response.id,
  572. label: response.name
  573. }
  574. })
  575. // this.initData()
  576. })
  577. },
  578. // 字典获取试验类型下拉列表
  579. initDictConfig() {
  580. //获取字典 你的字典名称 ⬇⬇⬇⬇
  581. ajaxGetDictItems('shiiyan_type').then((res) => {
  582. console.log('字典',res)
  583. this.tasks.collections.testTypeOptions = res.result.map(response =>{
  584. return {
  585. key: response.value,
  586. value: response.value,
  587. label: response.label
  588. }
  589. })
  590. // this.testTypeOptions = res.result
  591. //this.initData()
  592. })
  593. },
  594. // 通过委托编号查询检测项目
  595. getHjlist(){
  596. let that = this
  597. var queryParam = that.tasks.queryParam
  598. console.log(22,queryParam)
  599. getXmjlList(queryParam).then((res) => {
  600. console.log(17,res)
  601. that.tasks.data = []
  602. gantt.clearAll();
  603. if (res.result.length > 0 ) {
  604. that.tasks.data = res.result.map(res => {
  605. return {
  606. id: res.id,
  607. parent: res.parent,
  608. weituoId: res.weituoId,
  609. testItemsId: res.testItemsId,
  610. yangpinId:res.yangpinId,
  611. shebeiId:res.shebeiId,
  612. pm: res.pm,
  613. reportNo: res.reportNo,
  614. chuanganqiArray:res.chuanganqiArray,
  615. testPlanId:res.testPlanId,
  616. status:res.status,
  617. pm: res.pm,
  618. weituoNo: res.weituoNo,
  619. neirong: res.neirong,
  620. start_date: res.jihuaStartDate,
  621. // jihuaEndDate: res.jihuaEndDate,
  622. shiiyanTypeArray: res.shiiyanTypeArray,
  623. shijiStartDate: res.shijiStartDate,
  624. worker: res.worker,
  625. yangpinCount:res.yangpinCount,
  626. duration: res.lastTime,
  627. sampleName: res.sampleName,
  628. testItems: res.testItems,
  629. deviceName: res.deviceName,
  630. statusC: res.statusC
  631. }
  632. })
  633. gantt.init(this.$refs.gantt);
  634. gantt.parse(that.tasks);
  635. // gantt.init(this.$refs.gantt);
  636. // // gantt.parse(this.$props.tasks);
  637. // gantt.parse(this.tasks);
  638. } else {
  639. notification.open({
  640. message: '注意',
  641. description: '该委托编号不存在',
  642. });
  643. }
  644. // gantt.init(this.$refs.gantt);
  645. // gantt.parse(this.tasks);
  646. })
  647. },
  648. // // 提交
  649. // searchReset() {
  650. // var json = gantt.serialize();
  651. // console.log(json)
  652. // var data = json.data.map( res => {
  653. // return{
  654. // weituoId: res.weituoId,
  655. // testItemsId: res.testItemsId,
  656. // yangpinId:res.yangpinId,
  657. // shebeiId:res.shebeiId,
  658. // pm: res.pm,
  659. // jihuaStartDate: res.start_date,
  660. // lastTime: res.duration,
  661. // // jihuaEndDate: res.jihuaEndDate,
  662. // reportNo: res.reportNo,
  663. // chuanganqiArray:res.chuanganqi,
  664. // testPlanId:res.testPlanId,
  665. // status:res.status,
  666. // testItems: res.testItems,
  667. // }
  668. // })
  669. // console.log(data.length)
  670. // },
  671. }
  672. }
  673. </script>
  674. <style>
  675. @import "~dhtmlx-gantt/codebase/dhtmlxgantt.css";
  676. .gantt_cal_larea{
  677. overflow:visible;
  678. }
  679. .gantt_cal_larea{
  680. padding-bottom: 10px;
  681. }
  682. .gantt_cal_chosen,
  683. .gantt_cal_chosen select{
  684. width: 400px;
  685. margin-bottom: 10px;
  686. }
  687. /* ::v-deep .gantt_task_content{
  688. font-size: 8px !important;
  689. } */
  690. .taskProgress{
  691. margin: 0 auto;
  692. margin-top: 5px;
  693. height: 24px;
  694. width: 65px;
  695. font-size: 12px;
  696. line-height: 24px;
  697. font-weight: bold;
  698. color: #f7fbfe;
  699. border-radius: 20px;
  700. }
  701. .color_bg_1{
  702. background-color:#60a3bc ;
  703. }
  704. .color_bg_2{
  705. background-color:#079992 ;
  706. }
  707. .color_bg_3{
  708. background-color:#78e08f ;
  709. }
  710. .nested_task .gantt_add{
  711. display: none !important;
  712. }
  713. .noShow{
  714. display: none !important;
  715. }
  716. </style>