ProgressReportAdd.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. <template>
  2. <view>
  3. <uni-forms ref="form" labelPosition="left" labelAlign="left" @submit="submitForm">
  4. <view class="uni-form-item uni-column">
  5. <view class="title"><text class="uni-form-item__title">工作项名称</text></view>
  6. <view class="uni-input-wrapper">
  7. {{progressName+'->'+progressNodeName}}
  8. </view>
  9. </view>
  10. <view class="uni-form-item uni-column">
  11. <view class="title"><text class="uni-form-item__title">进度计划名称</text></view>
  12. <view class="uni-input-wrapper">
  13. {{progressName}}
  14. </view>
  15. </view>
  16. <view class="uni-form-item uni-column">
  17. <view class="title"><text class="uni-form-item__title">报告日期</text></view>
  18. <view class="uni-input-wrapper" style="justify-content: left;">
  19. <picker mode="date" @change="bindDateChange" v-model="reportDate" style="width: 100%;">
  20. <view class="uni-input">{{reportDate}}</view>
  21. </picker>
  22. </view>
  23. </view>
  24. <view class="uni-form-item uni-column">
  25. <view class="title"><text class="uni-form-item__title">填报进度</text></view>
  26. <view class="uni-input-wrapper">
  27. <view style="width: 200px;">
  28. <input class="uni-input" focus value="0" v-model="completePercent" type="number" /></view>
  29. <view>%</view>
  30. </view>
  31. </view>
  32. <view class="uni-form-item uni-column">
  33. <view class="title"><text class="uni-form-item__title">实际开始时间</text></view>
  34. <view class="uni-input-wrapper" style="justify-content: left;">
  35. <picker mode="date" @change="bindDealDateChange" v-model="actualStartDate" style="width: 100%;">
  36. <view class="uni-input">{{actualStartDate}}</view>
  37. </picker>
  38. </view>
  39. </view>
  40. <view class="uni-form-item uni-column">
  41. <view class="title"><text class="uni-form-item__title">实际结束时间</text></view>
  42. <view class="uni-input-wrapper" style="justify-content: left;">
  43. <picker mode="date" @change="bindFinishDateChange" v-model="actualFinishDate" style="width: 100%;">
  44. <view class="uni-input">{{actualFinishDate}}</view>
  45. </picker>
  46. </view>
  47. </view>
  48. <view class="uni-form-item uni-column">
  49. <view class="title"><text class="uni-form-item__title">执行情况</text></view>
  50. <view class="uni-textarea">
  51. <textarea focus placeholder="请填写执行情况" v-model="remark" auto-height="true" />
  52. </view>
  53. </view>
  54. <view class="uni-form-item uni-column">
  55. <view class="title" style="background-color: #efefef;"><text class="uni-form-item__title">附件</text></view>
  56. <view class="content">
  57. <g-upfile ref='gUpfile' :mode="imgList" @chooseFile='chooseFile' @imgDelete='imgDelete' :control='control'
  58. :columnNum="columnNum" :maxCount="maxCount" @limitFileSizeList='limitFileSizeList' @limitFileTypeList='limitFileTypeList' :maxFileSize="20000"></g-upfile>
  59. </view>
  60. </view>
  61. <view style="margin-bottom: 60px;">
  62. </view>
  63. <view class="uni-btn-v uni-column">
  64. <button type="primary" form-type="submit" style="border-radius: 15px;" >确定</button>
  65. </view>
  66. </uni-forms>
  67. </view>
  68. </template>
  69. <script>
  70. import {InsertProgressReport} from "@/common/api/ProgressApi.js";
  71. import {Decimal} from 'decimal.js'; //decimal计算
  72. export default {
  73. data() {
  74. return {
  75. progressId:this.$util.getQuery("progressId"),
  76. progressName:this.$util.getQuery("progressName"), //进度计划名
  77. progressNodeId:this.$util.getQuery("progressNodeId"),
  78. progressNodeName:this.$util.getQuery("progressNodeName"), //工作项名称
  79. reportDate:this.$util.getDate({
  80. format: true
  81. }),
  82. completePercent:0,
  83. remark:'',
  84. actualStartDate:'',
  85. actualFinishDate:'',
  86. imageList: [],
  87. countIndex: 5,
  88. count: [1, 2, 3, 4, 5],
  89. title1: 'picker',
  90. array: [],
  91. index: 0,
  92. control: true,
  93. columnNum: 3,
  94. imgList: [],
  95. urlList:[],
  96. maxCount:5
  97. }
  98. },
  99. onLoad(){
  100. //console.info(page.path);
  101. console.info(uni.getStorageSync('storage_state'));
  102. //console.info(this);
  103. this.$util.persistLogin(this);
  104. //console.info(this.$store.state.user);
  105. },
  106. onUnload() {
  107. this.imageList = [];
  108. },
  109. created: function() {
  110. },
  111. updated:function(){
  112. },
  113. methods: {
  114. /**
  115. * 手动提交
  116. * @param {Object} form
  117. */
  118. submitForm(e) {
  119. console.info('submitForm');
  120. let _this=this;
  121. if(this.progressNodeId=='')
  122. {
  123. uni.showToast({
  124. icon:"none",
  125. title:"请填写工作项名称",
  126. duration:3000
  127. });
  128. return;
  129. }
  130. if(this.progressId=='')
  131. {
  132. uni.showToast({
  133. icon:"none",
  134. title:"请填写进度计划名称",
  135. duration:3000
  136. });
  137. return;
  138. }
  139. if(this.reportDate==='')
  140. {
  141. uni.showToast({
  142. icon:"none",
  143. title:"请选择报告日期",
  144. duration:3000
  145. });
  146. return;
  147. }
  148. if(this.completePersent<=0)
  149. {
  150. uni.showToast({
  151. icon:"none",
  152. title:"请填报进度",
  153. duration:3000
  154. });
  155. return;
  156. }
  157. if(this.completePersent>100)
  158. {
  159. uni.showToast({
  160. icon:"none",
  161. title:"填报进度不能大于100",
  162. duration:3000
  163. });
  164. return;
  165. }
  166. if(this.actualStartDate===""){
  167. uni.showToast({
  168. icon:"none",
  169. title:"请选择实际开始日期",
  170. duration:3000
  171. });
  172. return;
  173. }
  174. if(this.completePersent==100&&this.actualFinishDate===""){
  175. uni.showToast({
  176. icon:"none",
  177. title:"请选结束日期",
  178. duration:3000
  179. });
  180. return;
  181. }
  182. if(this.remark!==""){
  183. if(this.remark.length>500){
  184. uni.showToast({
  185. icon:"none",
  186. title:"备注不能超过500字",
  187. duration:3000
  188. });
  189. return;
  190. }
  191. }
  192. let actualFinishDate=null;
  193. var data={projectCode:_this.$util.getState(_this,'projectCode'),progressId:_this.progressId-0,progressNodeId:_this.progressNodeId-0,reportDate:_this.reportDate,completePercent:_this.completePercent-0,actualStartDate:_this.actualStartDate,actualFinishDate:_this.actualFinishDate==''?actualFinishDate:_this.actualFinishDate,remark:_this.remark,inputPerson:_this.$util.getState(_this,'userCode')};
  194. console.info('data:',data);
  195. //return;
  196. InsertProgressReport(data).then((res)=>{
  197. console.info("提交应答");
  198. console.info(res);
  199. if(res=="-1")
  200. {
  201. uni.showToast({
  202. title:'进度不能小于等于0',
  203. icon:'none',
  204. duration:3000
  205. });
  206. return;
  207. }
  208. if(res=="-2")
  209. {
  210. uni.showToast({
  211. title:'进度不能大于等于100',
  212. icon:'none',
  213. duration:3000
  214. });
  215. return;
  216. }
  217. if(res){
  218. //上传图片
  219. _this.uploadFileToServe(res) ;
  220. uni.navigateTo({
  221. url:'/pages/template/GetpmProgressReportDTOs/GetpmProgressReportDTOs?progressNodeId='+_this.progressNodeId
  222. })
  223. }
  224. else{
  225. uni.showToast({
  226. title:'添加失败,重新操作',
  227. icon:'none',
  228. duration:3000
  229. })
  230. }
  231. });
  232. },
  233. /*
  234. 获取申请单
  235. */
  236. getRequisition() {
  237. let _this = this;
  238. _this.saveTemp(_this);
  239. //创建名字为fire的监听器,监听子页面传值事件
  240. uni.$on('requisition', function(data) {
  241. console.info("监听getRequisition子页面的传值", data);
  242. //console.info('监听',_this);
  243. _this.getTemp(_this);
  244. _this.requisitionCode=data[0].requisitionCode;
  245. _this.requisitionName=data[0].requisitionName;
  246. /* _this.$nextTick(function(){
  247. //更新dom
  248. }); */
  249. //接收一次监听,一旦监听到回传值,则清除监听事件,若不清除,会占用资源
  250. uni.$off("requisition");
  251. });
  252. uni.navigateTo({
  253. url: '/pages/template/SelectRelationRequision/SelectRelationRequision'
  254. });
  255. },
  256. delRow: function(index) {
  257. console.info("删除");
  258. console.info(this.costList[index]);
  259. this.costList.splice(index, 1);
  260. },
  261. bindPickerChange: function(e) {
  262. //console.log('picker发送选择改变,携带值为:' + e.detail.value);
  263. //console.info(e.detail);
  264. this.index = e.detail.value;
  265. this.viseType=this.array[this.index];
  266. console.info(this.viseType);
  267. },
  268. bindDateChange: function(e) {
  269. let date = e.detail.value;
  270. this.reportDate=date;
  271. console.info('bindDateChange',this.reportDate);
  272. },
  273. bindDealDateChange: function(e) {
  274. let date = e.detail.value;
  275. this.actualStartDate=date;
  276. console.info('bindDealDateChange',this.actualStartDate);
  277. },
  278. bindFinishDateChange:function(e){
  279. let date = e.detail.value;
  280. this.actualFinishDate=date;
  281. console.info('bindFinishDateChange',this.actualFinishDate);
  282. },
  283. /*
  284. 上传后返回的值:
  285. list:上传后图片数组
  286. v:返回当前上传图片的临时路径
  287. */
  288. chooseFile(list, v) {
  289. console.log("上传图片_list:", list)
  290. console.log("上传图片_v:", v);
  291. this.urlList=list;
  292. console.info("urlList",this.urlList);
  293. },
  294. /*
  295. 删除图片:
  296. list:删除返回删除后剩余的图片数组
  297. eq:返回删除的数组
  298. */
  299. imgDelete(list, eq) {
  300. console.log("删除图片_list:", list);
  301. console.log("删除图片_eq:", eq);
  302. this.urlList=list;
  303. console.info("urlList",this.urlList);
  304. },
  305. /*限制文件大小列表*/
  306. limitFileSizeList(list){
  307. console.info('limitFileSizeList:',list);
  308. if(list){
  309. if(list.length>0){
  310. uni.showModal({
  311. title:'警告',
  312. content: list.join()+' 文件大小超过2000KB',
  313. showCancel:false
  314. });
  315. }
  316. }
  317. },
  318. /*限制文件类型列表*/
  319. limitFileTypeList(list,allowFileType){
  320. console.info('limitFileTypeList:',list);
  321. console.info('limitFileTypeList:',allowFileType);
  322. if(list){
  323. if(list.length>0){
  324. uni.showModal({
  325. title:'警告',
  326. content: list.join()+' 文件类型必须是'+allowFileType.join(),
  327. showCancel:false
  328. });
  329. }
  330. }
  331. },
  332. /*
  333. 执行上传服务:
  334. urlList:要上传的图片:数组类型
  335. */
  336. uploadFileToServe(masterCode) {
  337. let _this=this;
  338. var urlList=_this.urlList;
  339. if (!urlList || urlList.length <= 0) {
  340. return;
  341. };
  342. //console.info(urlList);
  343. //return;
  344. for (let i = 0; i < urlList.length; i++) {
  345. uni.uploadFile({
  346. url: '/api/Common/UploadImage',
  347. filePath: urlList[i],
  348. name: 'file',
  349. formData: {
  350. createPerson:_this.$store.state.user.userCode,
  351. masterCode:masterCode,
  352. attachMentType:'---ProgressReportAttachment'
  353. },
  354. headers: {
  355. 'Content-Type': 'multipart/form-data; boundary = ' + new Date().getTime()
  356. //这里要把content-type设置为multipard/form-data,同时还要设置boundary
  357. },
  358. success: (uploadFileRes) => {
  359. console.log("图片上传:",uploadFileRes.data);
  360. }
  361. });
  362. }
  363. },
  364. }
  365. }
  366. </script>
  367. <style scoped>
  368. /* 头条小程序组件内不能引入字体 */
  369. /* #ifdef MP-TOUTIAO */
  370. @font-face {
  371. font-family: uniicons;
  372. font-weight: normal;
  373. font-style: normal;
  374. src: url("~@/static/uni.ttf") format("truetype");
  375. }
  376. /* #endif */
  377. page {
  378. display: flex;
  379. flex-direction: column;
  380. box-sizing: border-box;
  381. background-color: #efeff4;
  382. min-height: 100%;
  383. height: auto;
  384. }
  385. view {
  386. font-size: 14px;
  387. line-height: inherit;
  388. }
  389. .uni-form-item__title {
  390. font-size: 16px;
  391. line-height: 24px;
  392. }
  393. .uni-input-wrapper {
  394. /* #ifndef APP-NVUE */
  395. display: flex;
  396. /* #endif */
  397. padding: 8px 13px;
  398. flex-direction: row;
  399. flex-wrap: nowrap;
  400. background-color: #FFFFFF;
  401. -webkit-justify-content: left;
  402. }
  403. .title{
  404. background-color: #efefef;
  405. }
  406. .uni-icon {
  407. font-family: uniicons;
  408. font-size: 24px;
  409. font-weight: normal;
  410. font-style: normal;
  411. width: 24px;
  412. height: 24px;
  413. line-height: 24px;
  414. margin-left:15px;
  415. color: #999999;
  416. }
  417. .uni-eye-active {
  418. color: #007AFF;
  419. }
  420. .uni-btn-v{
  421. position: fixed;
  422. bottom: 0;
  423. width:100%;
  424. }
  425. .header-slot-box {
  426. font-size:15px;
  427. margin: 5px 5px;
  428. width:20%;
  429. justify-content: center;
  430. }
  431. .body-slot-box {
  432. font-size:15px;
  433. margin: 5px 5px;
  434. width:40%;
  435. justify-content: center;
  436. }
  437. .footer-slot-box {
  438. font-size:15px;
  439. margin: 5px 5px;
  440. width:40%;
  441. justify-content: center;
  442. }
  443. .uni-textarea textarea{
  444. font-size:15px;
  445. }
  446. .content {
  447. padding: 40rpx;
  448. background-color: #fff;
  449. }
  450. /* 上传控件 */
  451. .uploadControl {
  452. border: 1rpx solid #eee;
  453. border-radius: 10rpx;
  454. width: 130rpx;
  455. display: block;
  456. height: 130rpx;
  457. text-align: center;
  458. line-height: 130rpx;
  459. font-size: 30rpx;
  460. color: #888;
  461. background-color: #eeeeee;
  462. }
  463. .topicon >>> .icon{
  464. border: #4CD964 2upx solid;
  465. }
  466. </style>