add.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. var addVue = new Vue({
  2. el: '#app',
  3. data() {
  4. return {
  5. baseAjaxUrl: apiurljs.login, //基础请求路径
  6. get_AccessToken: localStorage.getItem("GlWorkPlatform-AccessToken"), //请求时的验证参数
  7. userId: $.cookie("GlWorkPlatform-userid"),
  8. userName: $.cookie("GlWorkPlatform-chineseName"),
  9. nowTab: "1",
  10. editID: 0,
  11. formData: {
  12. PROCODE: "", //项目编号
  13. PRONAME: "", //项目名称
  14. LOCATION: "", //项目位置
  15. JSUNIT: "", //建设单位
  16. ZTZ: 0, //总投资
  17. NDTZ: 0, //年度投资
  18. REMARK: "", //内容描述
  19. STARTDATE: "", //日期
  20. ENDDATE: "", //竣工日期
  21. SJXKHXMCODE: "", //市绩效考核项目
  22. KHDATECODE: "", //考核时段
  23. ZRLEADER: "", //责任领导
  24. ZRMAN: "", //责任人
  25. }, //主表表单数据
  26. ruleValidate: {
  27. PROCODE: [
  28. {required: true, message: '项目编号不能为空', trigger: 'blur'}
  29. ],
  30. PRONAME: [
  31. {required: true, message: '项目名称不能为空', trigger: 'blur'}
  32. ],
  33. STARTDATE: [
  34. {required: true, message: '开始时间不能为空', trigger: 'change', pattern: /.+/},
  35. {required: true, message: '开始时间不能为空', trigger: 'blur', pattern: /.+/}
  36. ],
  37. ENDDATE: [
  38. {required: true, message: '结束时间不能为空', trigger: 'change', pattern: /.+/},
  39. {required: true, message: '结束时间不能为空', trigger: 'blur', pattern: /.+/}
  40. ]
  41. }, //主表表单校验规则
  42. SJXKHXMList: [], //市绩效考核项目列表
  43. KHDATEList: [], //考核时段列表
  44. yearColumns: [
  45. {
  46. title: '序号',
  47. type: 'index',
  48. width: 60,
  49. align: 'center'
  50. },
  51. {
  52. title: '投资年份',
  53. key: 'TZNF',
  54. align: 'center'
  55. },
  56. {
  57. title: '投资金额(万元)',
  58. key: 'NDTZ',
  59. align: 'center'
  60. },
  61. {
  62. title: '操作',
  63. key: 'action',
  64. align: 'center',
  65. width: 150,
  66. render: (h, params) => {
  67. return h('div', [
  68. h('Button', {
  69. props: {
  70. type: 'primary',
  71. size: 'small'
  72. },
  73. style: {
  74. marginRight: '10px'
  75. },
  76. on: {
  77. click: () => {
  78. this.openEditYearModal(params.row);
  79. }
  80. }
  81. }, '编辑'),
  82. h('Button', {
  83. props: {
  84. type: 'error',
  85. size: 'small'
  86. },
  87. on: {
  88. click: () => {
  89. this.delYearModal(params.row);
  90. }
  91. }
  92. }, '删除')
  93. ]);
  94. }
  95. }
  96. ],
  97. yearTableData: [],
  98. modalYear: false,
  99. modalYearObj: {
  100. ID:0,
  101. NDTZ: 0,
  102. TZNF: ""
  103. },
  104. ruleValidateModalYear: {
  105. NDTZ: [
  106. {required: true, message: '投资金额不能为空', trigger: 'blur'}
  107. ],
  108. TZNF: [
  109. {required: true, message: '投资年份不能为空', trigger: 'change', pattern: /.+/},
  110. {required: true, message: '投资年份不能为空', trigger: 'blur', pattern: /.+/}
  111. ]
  112. },
  113. loadingModalYear: true,
  114. taskColumns: [
  115. {
  116. title: '序号',
  117. type: 'index',
  118. width: 60,
  119. align: 'center'
  120. },
  121. {
  122. title: '任务名称',
  123. key: 'TASKNAME',
  124. align: 'center'
  125. },
  126. {
  127. title: '工作内容',
  128. key: 'TASKCONNECT',
  129. align: 'center'
  130. },
  131. {
  132. title: '责任单位',
  133. key: 'ZRUNIT',
  134. align: 'center'
  135. },
  136. {
  137. title: '操作',
  138. key: 'action',
  139. align: 'center',
  140. width: 150,
  141. render: (h, params) => {
  142. return h('div', [
  143. h('Button', {
  144. props: {
  145. type: 'primary',
  146. size: 'small'
  147. },
  148. style: {
  149. marginRight: '10px'
  150. },
  151. on: {
  152. click: () => {
  153. this.openEditTaskModal(params.row);
  154. }
  155. }
  156. }, '编辑'),
  157. h('Button', {
  158. props: {
  159. type: 'error',
  160. size: 'small'
  161. },
  162. on: {
  163. click: () => {
  164. this.delTaskModal(params.row);
  165. }
  166. }
  167. }, '删除')
  168. ]);
  169. }
  170. }
  171. ],
  172. taskTableData:[],
  173. modalTask: false,
  174. loadingModalTask: true,
  175. modalTaskObj: {
  176. ID:0,
  177. TASKNAME:"",
  178. TASKCONNECT:"",
  179. ZRUNIT:"",
  180. ZRUINPUTNAME:"",
  181. USERID:""
  182. },
  183. ruleValidateModalTask: {
  184. TASKNAME: [
  185. {required: true, message: '任务名称不能为空', trigger: 'blur'}
  186. ],
  187. TASKCONNECT: [
  188. {required: true, message: '工作内容不能为空', trigger: 'blur'}
  189. ],
  190. ZRUNIT: [
  191. {required: true, message: '责任单位不能为空', trigger: 'blur'},
  192. {required: true, message: '任务名称不能为空', trigger: 'change'}
  193. ]
  194. },
  195. ZRUNITList:[]
  196. }
  197. },
  198. computed: {},
  199. methods: {
  200. //保存表单函数
  201. saveFormData: (name) => {
  202. _this.$refs[name].validate((valid) => {
  203. if (valid) {
  204. var postData = {
  205. ID: _this.editID,
  206. TABLENAME: "KEYPROJECT",
  207. PROCODE: _this.formData.PROCODE, //项目编号
  208. PRONAME: _this.formData.PRONAME, //项目名称
  209. LOCATION: _this.formData.LOCATION, //项目位置
  210. JSUNIT: _this.formData.JSUNIT, //建设单位
  211. ZTZ: _this.formData.ZTZ, //总投资
  212. NDTZ: _this.formData.NDTZ, //年度投资
  213. REMARK: _this.formData.REMARK, //内容描述
  214. STARTDATE: _this.formData.STARTDATE, //日期
  215. ENDDATE: _this.formData.ENDDATE, //竣工日期
  216. SJXKHXMCODE: _this.formData.SJXKHXMCODE, //市绩效考核项目
  217. KHDATECODE: _this.formData.KHDATECODE, //考核时段
  218. SJXKHXM: "",
  219. KHDATE: "",
  220. ZRLEADER: _this.formData.ZRLEADER, //责任领导
  221. ZRMAN: _this.formData.ZRMAN, //责任人
  222. ZRUNIT: "",
  223. PRODATE: sp.dateFtt("yyyy-MM-dd", new Date()),
  224. PROUSER: _this.userName,
  225. PROUSERID: _this.userId,
  226. SORTID: 0
  227. }
  228. _this.KHDATEList.forEach(function (item) {
  229. if (item.CODE == _this.formData.KHDATECODE) {
  230. console.log(item.CNAME);
  231. postData.KHDATE = item.CNAME;
  232. }
  233. })
  234. _this.SJXKHXMList.forEach(function (item) {
  235. if (item.CODE == _this.formData.SJXKHXMCODE) {
  236. console.log(item.CNAME);
  237. postData.SJXKHXM = item.CNAME;
  238. }
  239. })
  240. $http({
  241. method: 'post',
  242. headers: {
  243. 'Content-Type': 'application/json',
  244. 'Authorization': "Bearer " + _this.get_AccessToken
  245. },
  246. baseURL: _this.baseAjaxUrl,
  247. url: 'g2app/duchaduban/insertOrUpData',
  248. data: postData
  249. }).then(res => {
  250. console.log(res);
  251. if (res.data.success) {
  252. _this.editID = res.data.data.id;
  253. _this.$Message.success('操作成功!');
  254. } else {
  255. _this.$Message.error('操作失败请联系管理员!');
  256. }
  257. })
  258. } else {
  259. _this.$Message.error('表单验证失败!');
  260. }
  261. })
  262. },
  263. //获取市绩效考核项目
  264. getSJXKHXMList: () => {
  265. return $http({
  266. method: 'post',
  267. headers: {
  268. 'Content-Type': 'application/json',
  269. 'Authorization': "Bearer " + _this.get_AccessToken
  270. },
  271. baseURL: _this.baseAjaxUrl,
  272. url: 'g2app/duchaduban/queryCode',
  273. data: {
  274. tablename: "CODE_SJXKHXM"
  275. }
  276. })
  277. },
  278. //获取考核时段
  279. getKHDATEList: () => {
  280. return $http({
  281. method: 'post',
  282. headers: {
  283. 'Content-Type': 'application/json',
  284. 'Authorization': "Bearer " + _this.get_AccessToken
  285. },
  286. baseURL: _this.baseAjaxUrl,
  287. url: 'g2app/duchaduban/queryCode',
  288. data: {
  289. tablename: "CODE_KHSD"
  290. }
  291. })
  292. },
  293. //初始化函数
  294. initBaseData: () => {
  295. _this.SJXKHXMList = [];
  296. _this.KHDATEList = [];
  297. _this.ZRUNITList = [];
  298. $http.all([_this.getSJXKHXMList(), _this.getKHDATEList(),_this.getZRUNITList()]).then($http.spread((first, second,third) => {
  299. _this.SJXKHXMList = first.data.data;
  300. _this.KHDATEList = second.data.data;
  301. _this.ZRUNITList=third.data.data;
  302. console.log(_this.ZRUNITList)
  303. _this.formData.SJXKHXMCODE = _this.SJXKHXMList[0].CODE;
  304. _this.formData.KHDATECODE = _this.KHDATEList[0].CODE;
  305. if (_this.editID != 0) {
  306. //获取项目信息
  307. _this.getDatail();
  308. //获取年度投资信息
  309. _this.getYearData();
  310. //获取项目分解信息
  311. _this.getTaskData();
  312. } else {
  313. }
  314. }))
  315. },
  316. //返回列表页面
  317. goBack: () => {
  318. var returnPage = (sp.getUrlName("lastReturnPageno") != "" && sp.getUrlName("lastReturnPageno") != null && sp.getUrlName("lastReturnPageno") != undefined) ? sp.getUrlName("lastReturnPageno") : 1;
  319. location.href = "index.html?lastReturnPageno=" + returnPage;
  320. },
  321. //加载当前需要编辑的数据
  322. getDatail: () => {
  323. var postData = {
  324. id: _this.editID
  325. }
  326. $http({
  327. method: 'post',
  328. headers: {
  329. 'Content-Type': 'application/json',
  330. 'Authorization': "Bearer " + _this.get_AccessToken
  331. },
  332. baseURL: _this.baseAjaxUrl,
  333. url: 'g2app/duchaduban/getData',
  334. data: postData
  335. }).then(res => {
  336. _this.formData.PROCODE = res.data.data.PROCODE; //项目编号
  337. _this.formData.PRONAME = res.data.data.PRONAME; //项目名称
  338. _this.formData.LOCATION = res.data.data.LOCATION; //项目位置
  339. _this.formData.JSUNIT = res.data.data.JSUNIT; //建设单位
  340. _this.formData.ZTZ = res.data.data.ZTZ; //总投资
  341. _this.formData.NDTZ = res.data.data.NDTZ; //年度投资
  342. _this.formData.REMARK = res.data.data.REMARK; //内容描述
  343. _this.formData.STARTDATE = sp.dateFtt("yyyy-MM-dd", new Date(res.data.data.STARTDATE)); //日期
  344. _this.formData.ENDDATE = sp.dateFtt("yyyy-MM-dd", new Date(res.data.data.ENDDATE)); //竣工日期
  345. _this.formData.SJXKHXMCODE = res.data.data.SJXKHXMCODE; //市绩效考核项目
  346. _this.formData.KHDATECODE = res.data.data.KHDATECODE; //考核时段
  347. _this.formData.ZRLEADER = res.data.data.ZRLEADER; //责任领导
  348. _this.formData.ZRMAN = res.data.data.ZRMAN; //责任人
  349. })
  350. },
  351. //打开新增年度投资模态窗口
  352. openAddYearModal: (name) => {
  353. _this.modalYearObj.ID = 0;
  354. _this.modalYearObj.NDTZ = "";
  355. _this.modalYearObj.TZNF = "";
  356. _this.loadingModalYear = true;
  357. _this.modalYear = true;
  358. _this.$refs[name].resetFields();
  359. },
  360. //年度投资模态窗口确定函数
  361. okYearModal: (name) => {
  362. _this.$refs[name].validate((valid) => {
  363. if (valid) {
  364. _this.modalYear = false;
  365. _this.saveModalYearData();
  366. } else {
  367. _this.loadingModalYear = false
  368. _this.$nextTick(() => {
  369. _this.loadingModalYear = true
  370. })
  371. }
  372. })
  373. },
  374. //年度投资模态窗口取消函数
  375. cancelYearModal: (name) => {
  376. _this.modalYearObj.ID = 0;
  377. _this.modalYearObj.NDTZ = "";
  378. _this.modalYearObj.TZNF = "";
  379. _this.loadingModalYear = true;
  380. _this.$refs[name].resetFields();
  381. },
  382. //保存年度投资
  383. saveModalYearData: () => {
  384. var postData = {
  385. ID: _this.modalYearObj.ID,
  386. TABLENAME: "KEYPROJECT_06",
  387. PID: _this.editID,
  388. NDTZ: parseFloat(_this.modalYearObj.NDTZ),
  389. TZNF: _this.modalYearObj.TZNF
  390. }
  391. $http({
  392. method: 'post',
  393. headers: {
  394. 'Content-Type': 'application/json',
  395. 'Authorization': "Bearer " + _this.get_AccessToken
  396. },
  397. baseURL: _this.baseAjaxUrl,
  398. url: 'g2app/duchaduban/insertOrUpNDTZData',
  399. data: postData
  400. }).then(res => {
  401. if(res.data.success){
  402. _this.$Message.success('操作成功!');
  403. _this.getDatail();
  404. _this.getYearData();
  405. }else{
  406. _this.$Message.error('操作失败请联系管理员!');
  407. }
  408. })
  409. },
  410. //获取年度投资记录
  411. getYearData: () => {
  412. _this.yearTableData = [];
  413. var postData = {
  414. tablename: "KEYPROJECT_06",
  415. id: _this.editID,
  416. userid: ""
  417. }
  418. $http({
  419. method: 'post',
  420. headers: {
  421. 'Content-Type': 'application/json',
  422. 'Authorization': "Bearer " + _this.get_AccessToken
  423. },
  424. baseURL: _this.baseAjaxUrl,
  425. url: 'g2app/duchaduban/queryNTZData',
  426. data: postData
  427. }).then(res => {
  428. _this.yearTableData = res.data.data;
  429. })
  430. },
  431. //编辑年度投资按钮
  432. openEditYearModal:(editData)=>{
  433. console.log(editData);
  434. _this.modalYearObj.ID=editData.ID;
  435. _this.modalYearObj.NDTZ = editData.NDTZ + "";
  436. _this.modalYearObj.TZNF = editData.TZNF;
  437. _this.modalYear = true;
  438. },
  439. //删除年度投资按钮
  440. delYearModal:(editData)=>{
  441. var postData = {
  442. id:_this.editID,
  443. id_child:editData.ID,
  444. tablename_child:"KEYPROJECT_06",
  445. tablename:"KEYPROJECT",
  446. ndtz:parseFloat(editData.NDTZ),
  447. totndtz:parseFloat(_this.formData.NDTZ)
  448. }
  449. $http({
  450. method: 'post',
  451. headers: {
  452. 'Content-Type': 'application/json',
  453. 'Authorization': "Bearer " + _this.get_AccessToken
  454. },
  455. baseURL: _this.baseAjaxUrl,
  456. url: 'g2app/duchaduban/delNDTZData',
  457. data: postData
  458. }).then(res => {
  459. if(res.data.success){
  460. _this.$Message.success('操作成功!');
  461. _this.getYearData();
  462. _this.getDatail();
  463. }else{
  464. _this.$Message.error('操作失败请联系管理员!');
  465. }
  466. })
  467. },
  468. //打开任务分解弹出层
  469. openAddTaskModal:(name)=>{
  470. _this.modalTaskObj.ID = 0;
  471. _this.modalTaskObj.TASKNAME = "";
  472. _this.modalTaskObj.TASKCONNECT = "";
  473. _this.modalTaskObj.ZRUNIT = "";
  474. _this.modalTaskObj.ZRUINPUTNAME = "";
  475. _this.modalTaskObj.USERID = "";
  476. _this.loadingModalTask = true;
  477. _this.modalTask=true;
  478. _this.$refs[name].resetFields();
  479. },
  480. //任务分解模态窗口确定按钮
  481. okTaskModal:(name)=>{
  482. _this.$refs[name].validate((valid) => {
  483. if (valid) {
  484. _this.modalTask = false;
  485. _this.saveModalTaskData();
  486. } else {
  487. _this.loadingModalTask = false
  488. _this.$nextTick(() => {
  489. _this.loadingModalTask = true
  490. })
  491. }
  492. })
  493. },
  494. //任务分解模态窗口取消按钮
  495. cancelTaskModal:(name)=>{
  496. _this.modalTaskObj.ID = 0;
  497. _this.modalTaskObj.TASKNAME = "";
  498. _this.modalTaskObj.TASKCONNECT = "";
  499. _this.modalTaskObj.ZRUNIT = "";
  500. _this.modalTaskObj.ZRUINPUTNAME = "";
  501. _this.modalTaskObj.USERID = "";
  502. _this.loadingModalTask = true;
  503. _this.$refs[name].resetFields();
  504. },
  505. //获取责任单位列表
  506. getZRUNITList: () => {
  507. return $http({
  508. method: 'post',
  509. headers: {
  510. 'Content-Type': 'application/json',
  511. 'Authorization': "Bearer " + _this.get_AccessToken
  512. },
  513. baseURL: _this.baseAjaxUrl,
  514. url: 'g2app/duchaduban/queryZRUnit',
  515. data: {
  516. "ushowname":"",
  517. "zid":"AA06"
  518. }
  519. })
  520. },
  521. //选择责任单位
  522. changeZRUNIT:(value)=>{
  523. _this.ZRUNITList.forEach(function (item) {
  524. if(item.USHOWNAME==value){
  525. _this.modalTaskObj.USERID=item.USERID;
  526. _this.modalTaskObj.ZRUINPUTNAME=item.UINPUTNAME;
  527. }
  528. })
  529. },
  530. //保存任务分解
  531. saveModalTaskData: () => {
  532. var postData = {
  533. ID: _this.modalTaskObj.ID,
  534. PID: _this.editID,
  535. TABLENAME: "KEYPROJECT_04",
  536. TASKNAME:_this.modalTaskObj.TASKNAME,
  537. TASKCONNECT:_this.modalTaskObj.TASKCONNECT,
  538. ZRUNIT:_this.modalTaskObj.ZRUNIT,
  539. ZRUINPUTNAME:_this.modalTaskObj.ZRUINPUTNAME,
  540. USERID:_this.modalTaskObj.USERID
  541. }
  542. $http({
  543. method: 'post',
  544. headers: {
  545. 'Content-Type': 'application/json',
  546. 'Authorization': "Bearer " + _this.get_AccessToken
  547. },
  548. baseURL: _this.baseAjaxUrl,
  549. url: 'g2app/duchaduban/insertOrUpData',
  550. data: postData
  551. }).then(res => {
  552. if(res.data.success){
  553. _this.$Message.success('操作成功!');
  554. _this.getTaskData();
  555. }else{
  556. _this.$Message.error('操作失败请联系管理员!');
  557. }
  558. })
  559. },
  560. //获取任务分解记录
  561. getTaskData: () => {
  562. _this.taskTableData = [];
  563. var postData = {
  564. id: _this.editID
  565. }
  566. $http({
  567. method: 'post',
  568. headers: {
  569. 'Content-Type': 'application/json',
  570. 'Authorization': "Bearer " + _this.get_AccessToken
  571. },
  572. baseURL: _this.baseAjaxUrl,
  573. url: 'g2app/duchaduban/queryRWData',
  574. data: postData
  575. }).then(res => {
  576. _this.taskTableData = res.data.data;
  577. })
  578. },
  579. //编辑任务分解按钮
  580. openEditTaskModal:(editData)=>{
  581. console.log(editData);
  582. _this.modalTaskObj.ID = editData.ID;
  583. _this.modalTaskObj.TASKNAME = editData.TASKNAME;
  584. _this.modalTaskObj.TASKCONNECT = editData.TASKCONNECT;
  585. _this.modalTaskObj.ZRUNIT = editData.ZRUNIT;
  586. _this.modalTaskObj.ZRUINPUTNAME = editData.ZRUINPUTNAME;
  587. _this.loadingModalTask = true;
  588. _this.modalTask=true;
  589. },
  590. //删除任务分解按钮
  591. delTaskModal:(editData)=>{
  592. var postData = {
  593. tablename: "KEYPROJECT_04",
  594. id: editData.ID
  595. }
  596. $http({
  597. method: 'post',
  598. headers: {
  599. 'Content-Type': 'application/json',
  600. 'Authorization': "Bearer " + _this.get_AccessToken
  601. },
  602. baseURL: _this.baseAjaxUrl,
  603. url: 'g2app/duchaduban/del',
  604. data: postData
  605. }).then(res => {
  606. if(res.data.success){
  607. _this.$Message.success('操作成功!');
  608. _this.getTaskData();
  609. }else{
  610. _this.$Message.error('操作失败请联系管理员!');
  611. }
  612. })
  613. }
  614. },
  615. created: function () {
  616. _this = this;
  617. _this.baseAjaxUrl = apiurljs.login;
  618. _this.editID = (sp.getUrlName("ID") != undefined && sp.getUrlName("ID") != "" && sp.getUrlName("ID") != null) ? sp.getUrlName("ID") : 0;
  619. _this.initBaseData();
  620. },
  621. updated: function () {
  622. },
  623. mounted: function () {
  624. window.onresize = function () {
  625. var pageHeight = $(".boxContent").height();
  626. $(".contentBox").height($(".boxContent").height() - 50);
  627. };
  628. this.$nextTick(function () {
  629. var pageHeight = $(".boxContent").height();
  630. $(".contentBox").height($(".boxContent").height() - 50);
  631. });
  632. //项目阶段
  633. }
  634. });