Apply.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <div>
  3. <common @asynCallBack="asynCallBack"></common>
  4. <top-header :pageTitle="pageTitle"></top-header>
  5. <div class="mui-content vongi-wordcard">
  6. <div class="mui-content-padded vongi-wordcard-padded">
  7. <h5>当前打卡班次</h5>
  8. <h3>{{tjForm.workAttendanceDate}}<span v-text="tjForm.workAttendanceTime"></span></h3>
  9. </div>
  10. <div class="mui-content-padded">
  11. <form class="mui-input-group">
  12. <div class="mui-input-row">
  13. <label><span class="colorfe616c"></span>审批人</label>
  14. <div class="" >
  15. <span class="mui-btn mui-btn-block" type='button' >{{examinePerson.name}}</span>
  16. </div>
  17. </div>
  18. <div class="mui-input-row" v-if="false">
  19. <label><span class="colorfe616c">*</span>选择打卡类型</label>
  20. <div class="mui-navigate-right" @click="selectType">
  21. <span class="mui-btn mui-btn-block" v-text="typeName"></span>
  22. </div>
  23. </div>
  24. </form>
  25. </div>
  26. <div class="mui-content-padded">
  27. <h5><span class="colorfe616c">*</span>申请理由</h5>
  28. <div class="mui-input-row">
  29. <textarea v-model="tjForm.reason" rows="5" placeholder="请输入"></textarea>
  30. </div>
  31. </div>
  32. <div class="mui-content-padded">
  33. <h5>上传照片</h5>
  34. <div class="fyy-upphoto">
  35. <div class="mui-col-xs-3 fyy-upphoto-close" v-for="(item,index) in picList">
  36. <img :src="item" />
  37. <a class="mui-icon mui-icon-closeempty" @click="delPic(item)"></a>
  38. </div>
  39. <div class="mui-col-xs-3" @click="chooseImage">
  40. <a><span class="mui-icon mui-icon-plusempty"></span></a>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="vongi-btn">
  45. <button class="mui-btn " :class="examinePerson.name?'mui-btn-primary':'mui-btn-grey'" type="button" @click="submit">
  46. 提交
  47. </button>
  48. </div>
  49. </div>
  50. <loading :visible="isLoading"></loading>
  51. </div>
  52. </template>
  53. <script>
  54. import * as API_sp from '@/apis-xsy/xsy'
  55. require('$project/assets/js/mui.picker.min.js');
  56. import * as API_Attendance from '@/apis/Master/attendance'
  57. import Common from '$project/components/Common.vue'
  58. import Loading from '$project/components/Loading.vue'
  59. import TopHeader from '$project/components/TopHeader.vue'
  60. import {
  61. mapGetters,
  62. mapMutations
  63. } from 'vuex'
  64. import * as WxJsApi from '$project/utils/wxJsApi'
  65. import * as types from '$project/store/mutation-types'
  66. export default {
  67. name: 'MasterAttendanceApply',
  68. components: {
  69. Common,
  70. Loading,
  71. TopHeader
  72. },
  73. data() {
  74. return {
  75. pageTitle: '补卡申请',
  76. isLoading: false,
  77. examinePerson:{},
  78. subForm: {
  79. formId: "applyWork",
  80. workAttendanceId: this.$route.query.id
  81. },
  82. tjForm: {
  83. workAttendanceDate: '',
  84. workAttendanceTime: this.$route.query.time,
  85. type: '2', //外勤打卡/补卡(1/2)
  86. reason: '补卡申请',
  87. id: this.$route.query.id,
  88. imageUrl: '',
  89. longitude: '',
  90. latitude: '',
  91. formId: "applyWork",
  92. },
  93. //typeName: '',
  94. approvalPersonName: '刘攀',
  95. personList: [],
  96. picList: [],
  97. }
  98. },
  99. created() {
  100. },
  101. methods: {
  102. //获取详情
  103. getTime() {
  104. this.isLoading = true;
  105. API_Attendance.patchCard(this.subForm).then(response => {
  106. this.tjForm.workAttendanceDate = response.workAttendanceDate;
  107. this.tjForm.workAttendanceTime = response.workAttendanceTime;
  108. this.isLoading = false;
  109. }).catch(error => {
  110. this.isLoading = false;
  111. mui.toast(error);
  112. })
  113. },
  114. //获取审核人列表
  115. getPsersonList() {
  116. this.isLoading = true;
  117. //补卡1,外出2,出差3 ,请假4
  118. var parameter={type:1};
  119. API_Attendance.getApprovalList(parameter).then(response => {
  120. this.personList = response.data;
  121. this.isLoading = false;
  122. //设置默认审核人
  123. this.setDefaultExaminePerson();
  124. }).catch(error => {
  125. this.isLoading = false;
  126. mui.toast(error);
  127. })
  128. },
  129. //微信选择图片
  130. chooseImage() {
  131. WxJsApi.chooseImage().then(res => {
  132. var localData = res.localData;
  133. if (localData.indexOf('data:image') != 0) {
  134. //判断是否有这样的头部
  135. localData = 'data:image/jpeg;base64,' + localData
  136. }
  137. localData = localData.replace(/\r|\n/g, '').replace('data:image/jgp', 'data:image/jpeg')
  138. this.imgBase64 = localData;
  139. //显示裁剪图片
  140. //_this.showCropper(field);
  141. this.uploadpic();
  142. }).catch(error => {
  143. mui.toast(error);
  144. })
  145. },
  146. //上传图片
  147. uploadpic() {
  148. this.isLoading = true;
  149. WxJsApi.uploadPic(this.imgBase64).then(response => {
  150. this.isLoading = false;
  151. this.picList.push(response);
  152. }).catch(error => {
  153. this.isLoading = false;
  154. mui.toast(error);
  155. })
  156. },
  157. //选择审核人
  158. selectPerson() {
  159. var _this = this;
  160. var picker = new mui.PopPicker();
  161. picker.setData(_this.syPersonList);
  162. if (this.default_examine_person) {
  163. picker.pickers[0].setSelectedValue(this.default_examine_person);
  164. }
  165. picker.show(function(selectItems) {
  166. _this.tjForm.approvalPersonId = selectItems[0].value;
  167. _this.approvalPersonName = selectItems[0].text;
  168. _this.set_default_examine_person(selectItems[0].value);
  169. })
  170. },
  171. //设置默认审核人
  172. setDefaultExaminePerson() {
  173. if (this.default_examine_person) {
  174. for (var i = 0; i < this.syPersonList.length; i++) {
  175. if (this.syPersonList[i].value == this.default_examine_person) {
  176. this.tjForm.approvalPersonId = this.default_examine_person;
  177. this.approvalPersonName = this.syPersonList[i].text;
  178. }
  179. }
  180. }
  181. },
  182. //类型选择
  183. selectType() {
  184. var picker = new mui.PopPicker();
  185. if (this.tjForm.type = 2) {
  186. var data = [{
  187. value: '2',
  188. text: '补卡'
  189. }]
  190. } else {
  191. var data = [{
  192. value: '1',
  193. text: '外勤打卡'
  194. }]
  195. }
  196. picker.setData(data);
  197. var _this = this;
  198. picker.show(function(selectItems) {
  199. _this.tjForm.type = selectItems[0].value;
  200. //_this.typeName = selectItems[0].text;
  201. })
  202. },
  203. //表单检测
  204. checkFrom() {
  205. if (!this.tjForm.type) {
  206. mui.toast('请选择打卡类型');
  207. return false;
  208. } else if (false) {
  209. mui.toast('请选择审批人');
  210. return false;
  211. } else if (!this.tjForm.reason) {
  212. mui.toast('请输入申请内容');
  213. return false;
  214. } else {
  215. return true;
  216. }
  217. },
  218. //提交
  219. submit() {
  220. if(!this.examinePerson.name){
  221. return;
  222. }
  223. this.tjForm.imageUrl = this.picList.join(',');
  224. if (this.checkFrom()) {
  225. this.isLoading = true;
  226. API_Attendance.supplementWorkSubmit(this.tjForm).then(response => {
  227. this.isLoading = false;
  228. mui.toast('提交成功');
  229. this.$router.replace({
  230. name: "XsyApprovalInfo",
  231. query:{id:response.id,formId:'applyWork'}
  232. })
  233. }).catch(error => {
  234. this.isLoading = false;
  235. mui.toast(error);
  236. })
  237. }
  238. },
  239. //删除图片
  240. delPic(item) {
  241. let picList = this.picList;
  242. let index = picList.indexOf(item);
  243. if (index > -1) {
  244. picList.splice(index, 1);
  245. }
  246. this.picList = picList;
  247. },
  248. getExaminePerson(){
  249. API_sp.examinePerson(this.subForm.formId).then(response => {
  250. this.examinePerson=response
  251. }).catch(error => {
  252. mui.toast(error);
  253. })
  254. },
  255. asynCallBack() {
  256. },
  257. ...mapMutations({
  258. set_default_examine_person: types.SET_DEFAULT_EXAMINE_PERSON,
  259. })
  260. },
  261. mounted() {
  262. //获取微信配置
  263. WxJsApi.getWxConfig();
  264. //this.getTime();
  265. this.getExaminePerson();
  266. },
  267. destroyed() {},
  268. computed: {
  269. syPersonList: {
  270. // getter
  271. get: function() {
  272. let list = [];
  273. this.personList.forEach(function(item, index) {
  274. list.push({
  275. value: item.id,
  276. text: item.personName
  277. });
  278. })
  279. return list;
  280. },
  281. // setter
  282. set: function(newValue) {
  283. console.log(newValue)
  284. }
  285. },
  286. typeName: {
  287. // getter
  288. get: function() {
  289. if (this.tjForm.type == '1') {
  290. return '外勤打卡';
  291. } else if (this.tjForm.type == '2') {
  292. return '补卡';
  293. } else {
  294. return '无';
  295. }
  296. },
  297. // setter
  298. set: function(newValue) {
  299. console.log(newValue)
  300. }
  301. },
  302. ...mapGetters({
  303. openId: 'wx_openid',
  304. token: 'token',
  305. default_examine_person: 'default_examine_person'
  306. })
  307. }
  308. }
  309. </script>
  310. <style scoped src="$project/assets/css/xpwyfyy.css"></style>
  311. <style src="$project/assets/css/iconfont.css"></style>
  312. <style src="$project/assets/css/mui.picker.min.css"></style>
  313. <style scoped>
  314. </style>