demoForm2.vue 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966
  1. <template>
  2. <div class="form-main" id="form-main" >
  3. <div v-if="printTitle" class="no-print" style="text-align: right">
  4. <a-button v-if="printMould" :href="printMouldUrl" target="_blank"
  5. ghost type="primary">模板打印</a-button>
  6. <a-button v-if="printShow" v-print="'#printContent'" ghost type="primary">打印</a-button>
  7. </div>
  8. <a-card :body-style="{ padding: '15px 32px' }" :bordered="false" id="printContent" :class="{'abcdefg':true}" >
  9. <section ref="print" id="printContent" class="abcdefg">
  10. <!-- <a-form @submit="handleSubmit" :form="form">
  11. <a-form-item
  12. label="标题"
  13. :labelCol="{lg: {span: 7}, sm: {span: 7}}"
  14. :wrapperCol="{lg: {span: 10}, sm: {span: 17} }">
  15. <a-input :disabled="disabled"
  16. v-decorator="[
  17. 'name',
  18. {rules: [{ required: true, message: '请输入标题' }]}
  19. ]"
  20. name="name"
  21. placeholder="给目标起个名字" />
  22. </a-form-item>
  23. <a-form-item v-if="!disabled"
  24. :wrapperCol="{ span: 24 }"
  25. style="text-align: center"
  26. >
  27. <a-button htmlType="submit" type="primary" :disabled="disabled||btndisabled" @click="handleSubmit">保存</a-button>
  28. <a-button style="margin-left: 8px" :disabled="disabled" @click="close">取消</a-button>
  29. </a-form-item>
  30. </a-form>-->
  31. <k-form-build
  32. :value="jsonData"
  33. @change="handleChange"
  34. :dynamicData="dynamicData"
  35. ref="KFB"
  36. @submit="handleSubmit"
  37. />
  38. <div v-if="printTitleImg" style="text-align: right;margin-right: 13%">
  39. <!-- <img v-print="'#printContent'" ghost style="margin-top: -30px;" width="170px" height="80px" src="http://www.myfitt.cn:18087/jeecg-boot/sys/common/static/temp/20230310100319_1678417947827.png"/> -->
  40. <img v-print="'#printContent'" ghost style="margin-top: -30px;" width="340px" height="160px" src="http://www.myfitt.cn:18087/jeecg-boot/sys/common/static/temp/20230310100319_1678417947827.png"/>
  41. </div>
  42. </section>
  43. <div style="text-align:center">
  44. <a-button
  45. htmlType="submit"
  46. type="primary"
  47. :disabled="disabled || btndisabled"
  48. @click="handleSubmit"
  49. class="noprint"
  50. >保存</a-button>
  51. <todoManageOperation
  52. v-if="processData.operationType && processData.operationType == '1'"
  53. :processData="processData"
  54. :todoManageOperationObject="todoManageOperationObject"
  55. :disabled="disabled"
  56. :btndisabled="btndisabled"
  57. @refreshToDo="refreshToDo"
  58. @handleSubmit2="handleSubmit2"
  59. ></todoManageOperation>
  60. <a-button style="margin-left: 8px;" :disabled="disabled || disabled2" @click="close" class="noprint">取消</a-button>
  61. <!-- <a-button type="primary" v-if="printDisable" @click="changedd" class="noprint" style="margin-left:10px">打印</a-button> -->
  62. </div>
  63. </a-card>
  64. <personnel-files-modal ref="personnelFilesModal" @close="closeP"></personnel-files-modal>
  65. <fixed-zy-modal ref="FixedZyModal" @close="closeP"></fixed-zy-modal>
  66. <car-sq-modal ref="CarSqModal" @close="closeP"></car-sq-modal>
  67. <material-sl-modal ref="MaterialSlModal" @close="closeP"></material-sl-modal>
  68. </div>
  69. </template>
  70. <script>
  71. import pick from 'lodash.pick'
  72. import todoManageOperation from '../operation/todoManageOperation'
  73. import PersonnelFilesModal from './personnelFilesModal'
  74. import CarSqModal from './carSqModal'
  75. import MaterialSlModal from './materialSlModal'
  76. import FixedZyModal from './fixedZyModal'
  77. import { postAction, postFormDataAction} from '@/api/manage'
  78. import {annualLeave} from '@api/oa/cd-personnel-files'
  79. import moment from 'moment'
  80. import {getProjctName} from '../../../../url.config'
  81. import ACol from "ant-design-vue/es/grid/Col";
  82. import ARow from "ant-design-vue/es/grid/Row";
  83. import ATextarea from 'ant-design-vue/es/input/TextArea'
  84. export default {
  85. name: 'DemoForm',
  86. props: {
  87. reBizCode:{
  88. type: String,
  89. default: ''
  90. },
  91. /* 全局禁用,可表示查看 */
  92. disabled: {
  93. type: Boolean,
  94. default: false,
  95. required: false
  96. },
  97. /* 流程数据 */
  98. processData: {
  99. type: Object,
  100. default: () => {
  101. return {}
  102. },
  103. required: false
  104. },
  105. /* 是否新增 */
  106. isNew: { type: Boolean, default: false, required: false }
  107. },
  108. components: {
  109. ATextarea,
  110. ARow,
  111. ACol,
  112. todoManageOperation,
  113. moment,
  114. PersonnelFilesModal,
  115. FixedZyModal,
  116. CarSqModal,
  117. MaterialSlModal,
  118. },
  119. data () {
  120. return {
  121. printMould:false,
  122. printShow:true,
  123. printMouldUrl:'',
  124. printTitle:false,
  125. printTitleImg:false,
  126. isSJ: false,
  127. todoManageOperationObject: {
  128. isSave: false,
  129. formData: {},
  130. jsonData: {}
  131. },
  132. leave:0,//剩余年假
  133. disabled2: false, // 用来取决于表单时不同流程节点填写不同表单信息使用
  134. jsonData: {}, // 前台任意改变的json
  135. jsonDataSave: {}, // 保存到数据库的json
  136. url: {
  137. getForm: '/actBusiness/getForm',
  138. addApply: '/actBusiness/add',
  139. editForm: '/actBusiness/editForm',
  140. leaveType: '/sys/dict/getDictItems'
  141. },
  142. description: '流程表单demo,按例开发表单。需在 activitiMixin.js 中加入写好的表单',
  143. // form
  144. form: this.$form.createForm(this),
  145. /* 表单回显数据 */
  146. data: {},
  147. btndisabled: false,
  148. ceshi_file: null,
  149. fArr:[],//保存含有help的单个表单信息
  150. cvarr:[],//保存表单所有的label和key(用来寻找改变字段对应的key)
  151. bv:[],//保存所有含有help的表单信息
  152. dynamicData: {
  153. jsonData: {},
  154. typeData: [], // 请假类型下拉数据
  155. reimbursementTypeList: [], // 报销类型下拉数据
  156. invoiceTypeList: [], // 发票类型下拉数据
  157. add: this.add,
  158. gv:this.funName,
  159. department:[],//技能博物管下拉框信息
  160. personListJn:[],//技能博物馆人员信息下拉框
  161. fundApproval:[],//技能博物馆项目信息
  162. conferenceRoom:[],//技能博物馆会议室信息
  163. unit:[ //技能博物馆-物料库存-单位
  164. {label:'个',value:'个'},
  165. {label:'支',value:'支'},
  166. {label:'套',value:'套'},
  167. {label:'台',value:'台'},
  168. ]
  169. },
  170. postInfo: {},//职位信息
  171. deptInfo: {},//部门信息
  172. itemModelNameList: [], // 子表字段名
  173. buttonArr:[],
  174. printDisable:false//打印按钮
  175. }
  176. },
  177. watch: {
  178. // 'dynamicData.jsonData'(){
  179. // console.log("发生改变了")
  180. // },
  181. dynamicData: {
  182. handler (newName, oldName) {
  183. // console.log('obj.a changed')
  184. // console.log(newName)
  185. // console.log(oldName)
  186. newName.handle = this.funName1
  187. newName.fixed_zy = this.fixedZy
  188. newName.fixed_gh =this.fixedGh
  189. newName.fixed_db=this.fixedDb
  190. newName.fixed_bf=this.fixedBf
  191. newName.car_sq = this.carSq
  192. newName.material_sl = this.materialSl
  193. },
  194. immediate: true,
  195. deep: true
  196. }
  197. },
  198. created () {
  199. // debugger
  200. // console.log("==============="+this.processData);
  201. // console.log("==============="+this.processData.status);
  202. // console.log("==============="+this.processData.title);
  203. // console.log("==============="+this.processData.businessTable);
  204. // console.log("==============="+getProjctName());
  205. window.deleteRow = this.deleteRow
  206. // console.log('流程数据', this.processData)
  207. // 加载一些下拉选择数据等
  208. // this.getDataList()
  209. let businessTable = ''
  210. // 如果没有值则在另一个属性上有值
  211. if (!this.processData.businessTable) {
  212. this.processData.businessTable = this.processData.tableName
  213. }
  214. // debugger
  215. this.getAction('/tbTableInfo/query', {
  216. businessTable: this.processData.businessTable,
  217. taskNodeId: this.processData.key,
  218. tableId: this.processData.tableId,
  219. type: '1'
  220. }).then(res => {
  221. var jsonString = JSON.stringify(res.result.jsonContent)
  222. var index = 1
  223. var dynamicKeyValueList = []
  224. for (var index = 1; index !== -1;) {
  225. // 动态字符位置
  226. index = jsonString.indexOf('"dynamicKey"', index)
  227. if (index !== -1) {
  228. // 从指定字符的周后一个字符后开始找(")
  229. var ihStart = jsonString.indexOf('"', index + 12)
  230. // 再从 (") 后面位置还是找下一个 (")
  231. var ihEnd = jsonString.indexOf('"', ihStart + 1)
  232. // 获取引号之间的字符
  233. var dynamicKeyValue = jsonString.substring(ihStart + 1, ihEnd)
  234. // 如果动态表示不为空则获取
  235. if (dynamicKeyValue != '') {
  236. dynamicKeyValueList.push(dynamicKeyValue)
  237. }
  238. index = ihEnd + 1
  239. }
  240. }
  241. let that = this;
  242. if (dynamicKeyValueList.length > 0) {
  243. // 获取数据字典数据源
  244. postAction('/sys/dict/getDictItems/getDictList', dynamicKeyValueList).then(dictData => {
  245. if (dictData.success) {
  246. this.dynamicData = dictData.result.dicList
  247. if(getProjctName() =='技能博物馆'){
  248. //技能博物馆部门信息
  249. this.getAction('/sys/sysDepart/queryMyDeptList').then(res => {
  250. if (res.success) {
  251. var aa=[]
  252. res.result.map(item=>{
  253. aa.push({value:item.departName,label:item.departName})
  254. })
  255. this.dynamicData.department = aa
  256. } else {
  257. this.$message.error(res.message)
  258. }
  259. })
  260. //技能博物馆人员信息
  261. this.getAction('/sys/user/list', { pageSize: -1}).then(res => {
  262. if (res.success) {
  263. var aa = []
  264. res.result.records.map(item =>{
  265. aa.push(
  266. {value:item.realname,
  267. label:item.realname,
  268. workNo:item.workNo,
  269. post:item.post,
  270. nInductionTime:item.nInductionTimenInductionTime,
  271. phone:item.phone,
  272. telephone:item.telephone,
  273. departIds_dictText:item.orgCode,
  274. departIds:item.departIds
  275. })
  276. })
  277. this.dynamicData.personListJn = aa
  278. //技能博物馆 --- 全馆值班 此时无法触碰到handleChange方法 手动触发
  279. // if(this.processData.businessTable == 'bwg_house_duty'){
  280. // this.handleChange()
  281. // }
  282. } else {
  283. this.$message.error(res.message)
  284. }
  285. })
  286. //技能博物馆项目信息
  287. this.getAction('/oa/activiti/getSelectionList',{tableName:'bwg_project_start'}).then(res => {
  288. if (res.success) {
  289. var aa=[]
  290. res.result.map(item=>{
  291. aa.push(
  292. {value:item.project_name,
  293. label:item.project_name,
  294. startDate:item.start_date,
  295. endDate:item.end_date,
  296. projectReasons:item.project_reasons,
  297. budgetInformation:item.budget_information
  298. })
  299. })
  300. this.dynamicData.fundApproval = aa
  301. } else {
  302. this.$message.error(res.message)
  303. }
  304. })
  305. //技能博物馆会议室信息
  306. this.getAction('/oa/meetingRoom/all').then(res => {
  307. if (res.success) {
  308. var aa=[]
  309. res.result.map(item=>{
  310. aa.push({value:item.name,label:item.name})
  311. })
  312. this.dynamicData.conferenceRoom = aa
  313. } else {
  314. this.$message.error(res.message)
  315. }
  316. })
  317. }
  318. // 获取用户下拉数据
  319. this.getAction('/sys/user/list2', { pageSize: 20000 }).then(userData => {
  320. if (res.success) {
  321. if(userData.data != null && userData.data.supplierList != null){
  322. // userData.data.supplierList.forEach(user => {
  323. // console.log("userDatacode",user.code);
  324. // console.log("userDataname",user.name);
  325. // })
  326. this.dynamicData.supplierList = userData.data.supplierList
  327. this.dynamicData.customerList = userData.data.customerList
  328. this.dynamicData.userNameList = userData.data.userNameList
  329. this.dynamicData.userYWList = userData.data.userYWList
  330. this.dynamicData.userQCList = userData.data.userQCList
  331. }
  332. userData.result.records.forEach(user => {
  333. user.label = user.realname
  334. user.value = user.username
  335. that.postInfo[user.username] = user.post
  336. that.deptInfo[user.username] = user.deptName
  337. })
  338. // 存到动态数据源中
  339. this.dynamicData.userList = userData.result.records
  340. this.dynamicData.add = this.add // 新增按钮
  341. // 获取json
  342. this.jsonData = res.result.jsonContent
  343. // this.jsonData.list[2].columns[0].list[0].help = "date_1663752082983,date_1663753163575,min"
  344. this.cvarr = []
  345. this.cvarr = []
  346. this.fArr =[]
  347. //遍历help
  348. this.forHelp(this.jsonData)
  349. this.jsonDataSave = JSON.parse(JSON.stringify(res.result.jsonContent))
  350. // 获取申请人信息
  351. this.getApplicant()
  352. // 如果是手机端子表初始化子表model
  353. this.listUpdateModel()
  354. if (!this.isNew) {
  355. this.init()
  356. }
  357. } else {
  358. this.$message.error(userData.message)
  359. }
  360. })
  361. } else {
  362. this.$message.error(dictData.message)
  363. }
  364. })
  365. } else {
  366. // 获取json
  367. this.jsonData = res.result.jsonContent
  368. // this.jsonData.list[0].trs[5].tds[2].list[0].help = 'input_1662521241170,input_1662521240862,-'
  369. // this.jsonData.list[0].trs[3].tds[2].list[0].help = 'today'
  370. this.cvarr = []
  371. this.fArr =[]
  372. //遍历help(计算)
  373. this.forHelp(this.jsonData)
  374. // 获取申请人信息
  375. this.getApplicant()
  376. // 如果是手机端子表初始化子表model
  377. this.listUpdateModel()
  378. // window.jsonData=this.jsonData;
  379. if (!this.isNew) {
  380. this.init()
  381. }
  382. }
  383. // 后台检测到流程节点有关联表单且前台处于我的待办界面打开表单详情
  384. if (res.result.isSave && this.processData.isSuspended != undefined) {
  385. this.disabled = false
  386. this.btndisabled = false
  387. }
  388. })
  389. },
  390. methods: {
  391. fixedZy(){
  392. this.$refs.FixedZyModal.fixedZyModVis = true
  393. this.$refs.FixedZyModal.personLists('闲置')
  394. this.$refs.FixedZyModal.sat = '转移'
  395. },
  396. fixedGh(){
  397. this.$refs.FixedZyModal.fixedZyModVis = true
  398. this.$refs.FixedZyModal.personLists('领用,转移,调拨')
  399. this.$refs.FixedZyModal.sat = '归还'
  400. },
  401. fixedDb(){
  402. this.$refs.FixedZyModal.fixedZyModVis = true
  403. this.$refs.FixedZyModal.personLists('闲置')
  404. this.$refs.FixedZyModal.sat = '调拨'
  405. },
  406. fixedBf(){
  407. this.$refs.FixedZyModal.fixedZyModVis = true
  408. this.$refs.FixedZyModal.personLists('调拨,转移,领用,闲置')
  409. this.$refs.FixedZyModal.sat = '报废'
  410. },
  411. carSq(){
  412. this.$refs.CarSqModal.carSqModVis = true
  413. this.$refs.CarSqModal.personLists()
  414. },
  415. materialSl(){
  416. this.$refs.MaterialSlModal.materialSlModVis = true
  417. this.$refs.MaterialSlModal.personLists()
  418. },
  419. //获取部门信息
  420. getDepartment(){
  421. this.$refs.DepartmentModal.departmentModVis = true
  422. this.$refs.DepartmentModal.personLists()
  423. },
  424. closeP(value){
  425. var that = this
  426. this.cvarr.map(item=>{
  427. for(let key in value){
  428. if(item.model == key){
  429. setTimeout(function(){
  430. that.$refs.KFB.setData({[key]:value[key]})
  431. },0)
  432. }
  433. }
  434. })
  435. },
  436. funName1(){
  437. this.$refs.personnelFilesModal.declareElementsModVis = true
  438. this.$refs.personnelFilesModal.personLists()
  439. },
  440. // 根据字典名字获取数据源
  441. getDataListByName (name) {
  442. this.getAction(this.url.leaveType + '/' + name).then(res => {
  443. if (res.success) {
  444. this.dynamicData[name] = res.result
  445. console.log(111)
  446. } else {
  447. this.$message.error(res.message)
  448. }
  449. })
  450. },
  451. // 获取获取下拉数据等
  452. getDataList () {
  453. // 获取请假类型下拉数据
  454. this.getAction(this.url.leaveType + '/leave_type').then(res => {
  455. if (res.success) {
  456. this.dynamicData.typeData = res.result
  457. } else {
  458. this.$message.error(res.message)
  459. }
  460. })
  461. // 获取报销类型下拉数据
  462. this.getAction(this.url.leaveType + '/reimbursement_type').then(res => {
  463. if (res.success) {
  464. this.dynamicData.reimbursementTypeList = res.result
  465. } else {
  466. this.$message.error(res.message)
  467. }
  468. })
  469. // 获取发票类型下拉数据
  470. this.getAction(this.url.leaveType + '/invoice_type').then(res => {
  471. if (res.success) {
  472. this.dynamicData.invoiceTypeList = res.result
  473. } else {
  474. this.$message.error(res.message)
  475. }
  476. })
  477. },
  478. /* 回显数据 */
  479. init () {
  480. this.btndisabled = true
  481. var r = this.processData
  482. this.getAction(this.url.getForm, {
  483. tableId: r.tableId,
  484. tableName: r.tableName
  485. }).then(res => {
  486. // 第一次调接口根据子表数据渲染子表前台效果
  487. // 只有手机端才执行
  488. if (this.isSJ) {
  489. _.keys(res.result).forEach((e, i) => {
  490. if (e.indexOf('child&') != -1) {
  491. if (i > 0) {
  492. this.add()
  493. }
  494. }
  495. })
  496. }
  497. this.getAction(this.url.getForm, {
  498. tableId: r.tableId,
  499. tableName: r.tableName
  500. }).then(res => {
  501. if (res.success) {
  502. let formData = res.result
  503. formData.tableName = r.tableName
  504. // console.log("taboe",formData);
  505. this.data = formData
  506. // 如果表单是手机端的子表则
  507. if (this.isSJ) {
  508. var formModelList = _.keys(this.data)
  509. .join(',')
  510. .split(',')
  511. var itemList = []
  512. formModelList.forEach(element => {
  513. if (element.indexOf('child&') != -1) {
  514. itemList = JSON.parse(JSON.stringify(this.data[element]))
  515. delete this.data[element]
  516. }
  517. })
  518. // 子表字段名
  519. // 子表数据model和值组装
  520. itemList.forEach((item, index) => {
  521. this.itemModelNameList.forEach(itemModelName => {
  522. this.data[itemModelName + '@' + (index + 1)] = item[itemModelName]
  523. })
  524. })
  525. }
  526. // 赋值
  527. this.$refs.KFB.setData(this.data)
  528. this.btndisabled = false
  529. // debugger
  530. // console.log(this.processData);
  531. if(this.processData.result == 2){
  532. this.printTitle = true;
  533. if(this.processData.businessTable == 'meeting_summary'){ //会议纪要
  534. let leadership_pass = this.$refs.KFB.form.getFieldValue('leadership_pass');
  535. if(leadership_pass == 2){
  536. this.printTitleImg = false;
  537. }else{
  538. this.printTitleImg = true;
  539. }
  540. }else if(this.processData.businessTable == 'incident_ticket'){ //质量事故单
  541. this.printTitleImg = true;
  542. this.printShow = false;
  543. }else if(this.processData.businessTable == 'separation_application' || //离职
  544. this.processData.businessTable == 'personnel_recruitment_apply' || //人员需求
  545. this.processData.businessTable == 'regular_employee_apply' || //转正申请
  546. this.processData.businessTable == 'incident_ticket' || //质量事故单
  547. this.processData.businessTable == 'welfare'){ //福利发放单
  548. this.printTitleImg = true;
  549. }else if(this.processData.businessTable == 'expense_account'){//报销单
  550. let expense_type = this.$refs.KFB.form.getFieldValue('expense_type');
  551. if(expense_type != '差旅费报销'){ //业务需求报销/日常用品报销需要,其他不需要
  552. this.printTitleImg = true;
  553. }else{
  554. this.printTitleImg = false;
  555. }
  556. }else if(this.processData.businessTable == 'supplieses_apply_a'){//物质申请单
  557. var sonTable=[]
  558. // 获取子表数据
  559. _.keys(formData).forEach(r => {
  560. if (r.indexOf('child&') != -1) {
  561. sonTable=formData[r]
  562. }
  563. })
  564. if(sonTable[0].procurement_type !== '1'){ //公司采购,不显示签名
  565. this.printTitleImg = true;
  566. }else{
  567. this.printTitleImg = false;
  568. }
  569. }else{
  570. this.printTitleImg = false;
  571. }
  572. let that = this;
  573. let businessTable = this.processData.businessTable;
  574. if(this.printTitleImg){
  575. businessTable = businessTable+'_img'
  576. }
  577. this.getAction('/sys/dict/selectDictByJiMuPrint',{tableName:businessTable}).then(res => {
  578. if(res !=null && res !=''){
  579. that.printMouldUrl = res.value+'?'+res.text+'='+that.processData.tableId ;
  580. this.printMould = true;
  581. }else{
  582. this.printMould = false;
  583. }
  584. })
  585. }else{
  586. this.printTitleImg = false;
  587. this.printTitle = false;
  588. }
  589. } else {
  590. this.$message.error(res.message)
  591. }
  592. })
  593. })
  594. },
  595. //遍历help
  596. forHelp(obj){
  597. for(var a in obj){
  598. if (typeof(obj[a]) == "object"){
  599. if(obj[a].help !=='' && obj[a].help){
  600. //保存每一项的label和key
  601. this.cvarr.push({model:obj[a].model,key:obj[a].key,type:obj[a].type})
  602. obj[a].help = obj[a].help.split(',')
  603. //保存含有help的item中的label和help里的信息
  604. this.fArr=[
  605. {
  606. label:obj[a].model,
  607. value:'',
  608. },
  609. {
  610. label: obj[a].help[0],
  611. value:'',
  612. },
  613. {
  614. label: obj[a].help[1],
  615. value:'',
  616. },
  617. {
  618. label: obj[a].help[2],
  619. value:'',
  620. },
  621. ]
  622. //保存多各含有help的数据
  623. this.bv.push({bn:this.fArr})
  624. //默认当天时间
  625. this.defualtData(this.fArr)
  626. }else if(obj[a].help ==''){
  627. this.cvarr.push({model:obj[a].model,key:obj[a].key,type:obj[a].type})
  628. }else if(obj[a].type == 'button'){
  629. this.buttonArr.push(obj[a])
  630. this.buttonShow(obj[a])
  631. }
  632. this.forHelp(obj[a])
  633. }
  634. }
  635. },
  636. buttonShow(obj){
  637. if(obj.label == '打印'){
  638. this.printDisable = true
  639. }
  640. },
  641. //默认时间/默认当前账号
  642. defualtData(item){
  643. if(item[1].label =='today'){
  644. if(item[2].label){
  645. item[0].value =moment(new Date().toLocaleDateString()).format('YYYY-MM-DD')
  646. }else{
  647. item[0].value =moment(new Date().toLocaleDateString()).format('YYYY-MM-DD HH:mm')
  648. }
  649. var that = this
  650. setTimeout(function(){
  651. that.$refs.KFB.setData({[item[0].label]:item[0].value})
  652. },0)
  653. }else if(item[1].label =='deptName'){
  654. var that = this
  655. setTimeout(function(){
  656. that.$refs.KFB.setData({[item[0].label]:that.$store.getters.userInfo.deptName})
  657. },200)
  658. }else if(item[1].label =='user'){
  659. // this.$store.getters.userInfo
  660. var that = this
  661. setTimeout(function(){
  662. that.$refs.KFB.setData({[item[0].label]:that.$store.getters.userInfo.realname})
  663. // 森语-请假单-须根据当前用户带出剩余年假
  664. if(that.processData.businessTable =='employee_leave'){
  665. annualLeave({username:that.$store.getters.userInfo.username}).then(res => {
  666. if (res.success) {
  667. that.leave = res.result.nannualNowNum
  668. that.$refs.KFB.setData({leave_remaining: that.leave})
  669. }
  670. })
  671. }
  672. var jnDeparment = ''
  673. if(getProjctName() =='技能博物馆'){ //获取技能博物馆登录人对应的部门
  674. that.dynamicData.personListJn.map(item =>{
  675. if(item.label == that.$store.getters.nickname){
  676. jnDeparment = item.departIds_dictText
  677. }
  678. })
  679. }
  680. if(that.processData.businessTable == 'regular_employee_apply'){//员工转正申请
  681. that.$refs.KFB.setData({apply_department:that.deptInfo[that.$store.getters.userInfo.username]})
  682. // that.$refs.KFB.setData({job_title:that.postInfo[that.$store.getters.userInfo.username]})
  683. }
  684. if(that.processData.businessTable == 'seal_apply'){//用印申请单
  685. that.$refs.KFB.setData({apply_department:that.deptInfo[that.$store.getters.userInfo.username]})
  686. }
  687. if(that.processData.businessTable == 'separation_application'){//离职申请
  688. that.$refs.KFB.setData({job_title:that.postInfo[that.$store.getters.userInfo.username]})
  689. }
  690. if(that.processData.businessTable == 'bwg_house_duty'){ // 技能博物馆--全馆值班 --默认当前登陆人
  691. that.$refs.KFB.setData({referrer:that.$store.getters.nickname})
  692. that.dynamicData.personListJn.map(item =>{
  693. if(item.label == that.$store.getters.nickname){
  694. that.$refs.KFB.setData({department_id:item.departIds})
  695. that.$refs.KFB.setData({department_name:item.departIds_dictText})
  696. that.$refs.KFB.setData({mobile_telephone:item.phone})
  697. that.$refs.KFB.setData({telephone:item.telephone})
  698. }
  699. })
  700. }
  701. if(that.processData.businessTable == 'bwg_meeting_summary'){//技能博物馆 --- 会议纪要---默认当前登陆人
  702. that.dynamicData.personListJn.map(item =>{
  703. if(item.label == that.$store.getters.nickname){
  704. that.$refs.KFB.setData({record_person:item.value})
  705. that.$refs.KFB.setData({record_department:item.departIds_dictText})
  706. }
  707. })
  708. }
  709. //技能博物馆-物料库存
  710. if(that.processData.businessTable == 'material_apply'){
  711. that.$refs.KFB.setData({department:jnDeparment})
  712. }
  713. //技能博物馆-物料申领
  714. if(that.processData.businessTable == 'application_form'){
  715. that.$refs.KFB.setData({department:jnDeparment})
  716. }
  717. //技能博物馆-任务--默认当前登陆人部门
  718. if(that.processData.businessTable == 'task_management'){
  719. that.$refs.KFB.setData({initiate_department:jnDeparment})
  720. }
  721. //技能博物馆-固定资产-报废
  722. if(that.processData.businessTable == 'scrap_apply'){
  723. that.$refs.KFB.setData({apply_personnel_department:jnDeparment})
  724. }
  725. },0)
  726. annualLeave({username:that.$store.getters.userInfo.username}).then(res => {
  727. if (res.success) {
  728. this.leave = res.result.nannualNowNum
  729. }else{
  730. this.$message.error(res.message);
  731. }
  732. })
  733. }else if(item[1].label =='automatic'){
  734. var that = this
  735. setTimeout(function(){
  736. if(that.processData.businessTable == 'incident_ticket'){ // 森语-质量事故单-自动生成事故单号
  737. if( that.processData.tableId==''|| !that.processData.tableId){
  738. that.getAction('/sys/user/getNextNo',{name:'accidentCode'}).then(res => {
  739. that.$refs.KFB.setData({accident_number:res})
  740. })
  741. }
  742. }else if(that.processData.businessTable == 'expense_account'){//报销单-自动生成单号
  743. if( that.processData.tableId==''|| !that.processData.tableId){
  744. that.getAction('/sys/user/getNextNo',{name:'BXDCode'}).then(res => {
  745. that.$refs.KFB.setData({reimbursement_no:res})
  746. })
  747. }
  748. }
  749. },200)
  750. }
  751. },
  752. // 获取申请人信息
  753. getApplicant () {
  754. console.log('aa', this.$refs.KFB.form.getFieldValue('applicant'))
  755. // if (this.$refs.KFB.form.getFieldValue('applicant')) {
  756. // alert(1)
  757. // this.$refs.KFB.setData({
  758. // applicant: this.$store.getters.userInfo.username
  759. // })
  760. // }
  761. },
  762. changedd(){
  763. window.print()
  764. },
  765. //主子表计算
  766. tableCalculation(value){
  767. if(this.processData.businessTable == 'supplieses_apply_a' ){
  768. var number1 = 0,
  769. number2 = 0
  770. //寻找help信息中对应的modol值
  771. this.bv.map(item=>{
  772. this.cvarr.map(vv=>{
  773. if(vv.key == item.bn[1].label){
  774. number1 = vv.model
  775. }else if(vv.key == item.bn[2].label){
  776. number2 = vv.model
  777. }
  778. })
  779. //表中每一行分别计算
  780. var sum = 0
  781. value.map(b=>{
  782. b[item.bn[0].label] = (b[number1]*b[number2]).toFixed(2)
  783. sum += b[number1]*b[number2] //计算出表格内的总价总和
  784. if(this.$store.getters.nickname=='崔崇杰'){
  785. b['procurement_type']='1'
  786. }else if(b['procurement_type']=='' ||!b['procurement_type'] ){
  787. b['procurement_type']='2'
  788. }
  789. })
  790. sum = sum.toFixed(2)
  791. this.$refs.KFB.setData({sum:sum})
  792. })
  793. }
  794. if(this.processData.businessTable == 'incident_ticket'){
  795. var all = 0,
  796. currencys=[],
  797. currency =''
  798. value.map(item=>{
  799. item.accident_sum = item.accident_sum?item.accident_sum:'0'
  800. //计算表头总价
  801. all+=Number(item.accident_sum)
  802. //币种-自动带出
  803. if(item.money_type){currencys.push(item.money_type)}
  804. })
  805. //获取表格中只出现一次的币种-即为改变的币种
  806. currencys.every(item=>{
  807. const countOccurences = (arr, value) => arr.reduce((a, v) => v === value ? a + 1 : a + 0, 0)
  808. if(countOccurences(currencys,item)==1){
  809. currency=item
  810. return false
  811. }
  812. return true
  813. })
  814. //赋值
  815. value.map(item=>{
  816. //若无只出现一次的币种 1.第一次表格增行 2.表格中有两条以上数据,再次增行
  817. if(currency==''){
  818. item.money_type = currencys[0]
  819. }else{
  820. item.money_type = currency
  821. }
  822. })
  823. this.$refs.KFB.setData({total_money:all})
  824. }
  825. },
  826. specialTerms(value,key){
  827. var that = this
  828. //剩余年假
  829. if(key == 'employe_name'){
  830. setTimeout(function(){
  831. annualLeave({username:value}).then(res => {
  832. if (res.success) {
  833. //选择姓名获取页面的请假类型和时间间隔
  834. that.leave = res.result.nannualNowNum
  835. that.$refs.KFB.setData({leave_remaining: that.leave})
  836. var category = that.$refs.KFB.form.getFieldValue('leave_category')
  837. var time1 = that.$refs.KFB.form.getFieldValue('start_date')
  838. var time2 = that.$refs.KFB.form.getFieldValue('end_date')
  839. var timeC=that.timeDifference(time1,time2,'min') //获取时间差
  840. //事假,超过180分钟,年假大于0.5
  841. if(category == '事假' &&timeC>=180&&that.leave>=0.5){
  842. that.$refs.KFB.setData({unit:'天'})
  843. that.$refs.KFB.setData({leave_category:'年假'})
  844. }else if(category == '年假' && that.leave<0.5){ //类型为年假,剩余年假小于0.5
  845. that.$refs.KFB.setData({unit:'分'})
  846. that.$refs.KFB.setData({leave_category:''})
  847. that.$message.error('剩余年假不足!');
  848. }
  849. }else{
  850. that.$message.error(res.message);
  851. }
  852. })
  853. },0)
  854. }
  855. //请假类型与单位
  856. //事假
  857. if(key == 'leave_category' && value == '事假'){
  858. setTimeout(function(){
  859. var time1 = that.$refs.KFB.form.getFieldValue('start_date')
  860. var time2 = that.$refs.KFB.form.getFieldValue('end_date')
  861. var timeC=that.timeDifference(time1,time2,'min') //获取时间差
  862. if(timeC>=180 && that.leave>=0.5){ //事假,时间差大于180,剩余年假大于0.5
  863. that.$refs.KFB.setData({unit:'天'})
  864. that.$refs.KFB.setData({leave_category:'年假'})
  865. }else{
  866. that.$refs.KFB.setData({unit:'分'})
  867. }
  868. },0)
  869. }else if(key == 'leave_category' && value == '病假'){ //病假
  870. setTimeout(function(){
  871. that.$refs.KFB.setData({unit:'分'})
  872. },0)
  873. }else if(key == 'leave_category' && value == '年假'){//年假
  874. setTimeout(function(){
  875. if(that.leave >=0.5){ //剩余年假大于0.5
  876. that.$refs.KFB.setData({unit:'天'})
  877. }else{ //剩余年假小于0.5
  878. that.$refs.KFB.setData({unit:'分'})
  879. that.$refs.KFB.setData({leave_category:''})
  880. that.$message.error('剩余年假不足!');
  881. }
  882. },0)
  883. }else if(key == 'leave_category'){
  884. setTimeout(function(){
  885. that.$refs.KFB.setData({unit:'天'})
  886. },0)
  887. }
  888. //时间间隔和类型
  889. if(key =='start_date' || key =='end_date'){
  890. setTimeout(function(){
  891. var time2 = that.$refs.KFB.form.getFieldValue('end_date')
  892. var time1 = that.$refs.KFB.form.getFieldValue('start_date')
  893. var timeC=that.timeDifference(time1,time2,'min')
  894. var lx=that.$refs.KFB.form.getFieldValue('leave_category')
  895. if(timeC>=180&&lx=='事假'&&that.leave>=0.5){ //事假,时间差大于180,剩余年假大于0.5
  896. that.$refs.KFB.setData({unit:'天'})
  897. that.$refs.KFB.setData({leave_category:'年假'})
  898. }
  899. },0)
  900. }
  901. },
  902. // 表单字段数值发生改变事件
  903. handleChange (value, key) {
  904. if(key == 'proposer' && this.processData.businessTable == 'regular_employee_apply'){//员工转正申请:申请人部门
  905. this.$refs.KFB.setData({apply_department:this.deptInfo[value]})
  906. }
  907. if(key == 'regular_employee' && this.processData.businessTable == 'regular_employee_apply'){//员工转正申请:转正人员岗位
  908. this.$refs.KFB.setData({job_title:this.postInfo[value]})
  909. }
  910. if(key == 'proposer' && this.processData.businessTable == 'seal_apply'){//用印申请单
  911. this.$refs.KFB.setData({apply_department:this.deptInfo[value]})
  912. }
  913. if(key == 'employee_name' && this.processData.businessTable == 'separation_application'){//离职申请
  914. this.$refs.KFB.setData({job_title:this.postInfo[value]})
  915. }
  916. //森语-质量事故单
  917. if(key=='child&incident_ticket_children'){
  918. this.tableCalculation(value)
  919. }
  920. //技能博物馆-----退休录入
  921. if(key == 'name' && this.processData.businessTable == 'bwg_retire_input'){//技能博物馆 ---- 退休录入
  922. this.dynamicData.personListJn.map(item =>{
  923. if(item.label == value){
  924. this.$refs.KFB.setData({employee_number:item.workNo})
  925. this.$refs.KFB.setData({post:item.post})
  926. this.$refs.KFB.setData({rz_date:item.nInductionTim})
  927. }
  928. })
  929. // this.$refs.KFB.setData({employee_number:this.postInfo[value]})
  930. }
  931. //技能博物馆-----离职录入
  932. if(key == 'name' && this.processData.businessTable == 'bwg_quit_input'){//技能博物馆 ---- 退休录入
  933. this.dynamicData.personListJn.map(item =>{
  934. if(item.label == value){
  935. this.$refs.KFB.setData({employee_number:item.workNo})
  936. this.$refs.KFB.setData({post:item.post})
  937. this.$refs.KFB.setData({rz_date:item.nInductionTim})
  938. }
  939. })
  940. }
  941. //技能博物馆 ----- 费用报销
  942. if(key == 'expense_person' && this.processData.businessTable == 'bwg_expense_apply'){
  943. this.dynamicData.personListJn.map(item =>{
  944. if(item.label == value){
  945. this.$refs.KFB.setData({expense_department:item.departIds_dictText})
  946. }
  947. })
  948. }
  949. // 技能博物馆---用车申请
  950. if(key == 'car_automobilist' && this.processData.businessTable == 'car_apply'){
  951. this.dynamicData.personListJn.map(item =>{
  952. if(item.label == value){
  953. this.$refs.KFB.setData({car_department:item.departIds_dictText})
  954. }
  955. })
  956. }
  957. // // 技能博物馆---物料库存--金额计算
  958. // if((key == 'unit_price'||key=='amount') && this.processData.businessTable == 'material_apply'){
  959. // var that = this
  960. // setTimeout(function(){
  961. // var unit_price = that.$refs.KFB.form.getFieldValue('unit_price'),
  962. // amount = that.$refs.KFB.form.getFieldValue('amount'),
  963. // sum = Number(unit_price)*Number(amount)
  964. // that.$refs.KFB.setData({money:sum})
  965. // },0)
  966. // }
  967. // 技能博物馆---物料库存--部门
  968. if(key == 'input_account' && this.processData.businessTable == 'material_apply'){
  969. this.dynamicData.personListJn.map(item =>{
  970. if(item.label == value){
  971. this.$refs.KFB.setData({department:item.departIds_dictText})
  972. }
  973. })
  974. }
  975. if(key == 'task_executor' &&this.processData.businessTable == 'task_management'){
  976. this.dynamicData.personListJn.map(item =>{
  977. if(item.label == value){
  978. this.$refs.KFB.setData({task_department:item.departIds_dictText})
  979. }
  980. })
  981. }
  982. // 技能博物馆---物料申领--部门
  983. if(key == 'get_account' && this.processData.businessTable == 'application_form'){
  984. this.dynamicData.personListJn.map(item =>{
  985. if(item.label == value){
  986. this.$refs.KFB.setData({department:item.departIds_dictText})
  987. }
  988. })
  989. }
  990. // 技能博物馆---固定资产--归还
  991. if(key == 'uuse_personnel' && this.processData.businessTable == 'give_back'){
  992. this.dynamicData.personListJn.map(item =>{
  993. if(item.label == value){
  994. this.$refs.KFB.setData({use_department:item.departIds_dictText})
  995. }
  996. })
  997. }
  998. //技能博物馆-固定资产-报废
  999. if(key == 'apply_personnel' &&this.processData.businessTable == 'scrap_apply'){
  1000. this.dynamicData.personListJn.map(item =>{
  1001. if(item.label == value){
  1002. this.$refs.KFB.setData({apply_personnel_department:item.departIds_dictText})
  1003. }
  1004. })
  1005. }
  1006. //技能博物馆 ----资金审批
  1007. if(key == 'project_name' && this.processData.businessTable == 'bwg_capital_approval'){
  1008. this.dynamicData.fundApproval.map(item =>{
  1009. if(item.label == value){
  1010. this.$refs.KFB.setData({start_data:item.startDate})
  1011. this.$refs.KFB.setData({end_date:item.endDate})
  1012. this.$refs.KFB.setData({project_reasons:item.projectReasons})
  1013. this.$refs.KFB.setData({budget_information:item.budgetInformation})
  1014. }
  1015. })
  1016. }
  1017. //改变的表单是主子表类型时----物质申请单
  1018. if(key =='child&supplieses_apply'){
  1019. this.tableCalculation(value)
  1020. }
  1021. //特别字段
  1022. this.specialTerms(value,key)
  1023. //代码赘余,日后维护
  1024. //保存发生改变字段名对应的key
  1025. var cc ='',
  1026. type = ''
  1027. this.cvarr.map(k =>{
  1028. if(k.model ==key){
  1029. cc=k.key
  1030. type = k.type
  1031. }})
  1032. //根据数值改变计算
  1033. var that =this
  1034. setTimeout(function(){
  1035. that.bv.map(event =>{
  1036. if(event.bn[1].label == cc || event.bn[2].label == cc){
  1037. that.cvarr.map(k=>{
  1038. if(k.key == event.bn[1].label){
  1039. event.bn[1].value = that.$refs.KFB.form.getFieldValue(k.model)
  1040. }else if(k.key == event.bn[2].label){
  1041. event.bn[2].value = that.$refs.KFB.form.getFieldValue(k.model)
  1042. }
  1043. })
  1044. if(type == 'date'){
  1045. if(event.bn[1].value!=='' && event.bn[2].value!==''){
  1046. var state = ''
  1047. state = event.bn[3].label
  1048. event.bn[0].value = that.timeDifference(event.bn[1].value,event.bn[2].value,state)
  1049. }
  1050. }else{
  1051. if(event.bn[3].label =="+"){
  1052. event.bn[0].value = Number(event.bn[1].value)+Number(event.bn[2].value)
  1053. }else if(event.bn[3].label =="-"){
  1054. event.bn[0].value = Number(event.bn[1].value)-Number(event.bn[2].value)
  1055. }else if(event.bn[3].label =="*"){
  1056. event.bn[0].value = Number(event.bn[1].value)*Number(event.bn[2].value)
  1057. }
  1058. }
  1059. that.$refs.KFB.setData({[event.bn[0].label]:event.bn[0].value})
  1060. }
  1061. })
  1062. },0)
  1063. // // 数据变化时触发
  1064. // // 如果开始时间发生变化
  1065. // if (key == 'start_time') {
  1066. // // 判断结束时间是否存在
  1067. // if (this.$refs.KFB.form.getFieldValue('end_time')) {
  1068. // // 获取时间差
  1069. // let duration = startEndFun(value, this.$refs.KFB.form.getFieldValue('end_time'))
  1070. // if (duration) {
  1071. // // 使用k-form-design组件的form属性修改表单数据
  1072. // this.$refs.KFB.setData({
  1073. // duration: duration
  1074. // })
  1075. // }
  1076. // }
  1077. // }
  1078. // // 如果结束时间发生变化
  1079. // if (key == 'end_time') {
  1080. // // 判断结束时间是否存在
  1081. // if (this.$refs.KFB.form.getFieldValue('start_time')) {
  1082. // // 获取时间差
  1083. // let duration = startEndFun(this.$refs.KFB.form.getFieldValue('start_time'), value)
  1084. // if (duration) {
  1085. // // 使用k-form-design组件的form属性修改表单数据
  1086. // this.$refs.KFB.setData({
  1087. // duration: duration
  1088. // })
  1089. // }
  1090. // }
  1091. // }
  1092. },
  1093. // handler
  1094. handleSubmit (e) {
  1095. var that =this
  1096. // return new Promise((resolve)=>{
  1097. // 通过函数获取数据
  1098. this.$refs.KFB.getData()
  1099. .then(res => {
  1100. // let formData1 = JSON.parse(JSON.stringify(res))
  1101. // // 获取数据成功
  1102. // let formData = JSON.parse(JSON.stringify(res))
  1103. let formData1 = JSON.parse(JSON.stringify(res, (key, value) => typeof value === 'undefined' ? '' : value))
  1104. // 获取数据成功
  1105. let formData = JSON.parse(JSON.stringify(res, (key, value) => typeof value === 'undefined' ? '' : value))
  1106. var addForm = 'no'
  1107. if(this.processData.businessTable == 'employee_leave'){
  1108. var estimate = this.$refs.KFB.form.getFieldValue('leave_days'),
  1109. // actual = that.$refs.KFB.form.getFieldValue('practical_leave'),
  1110. leaveCategory = this.$refs.KFB.form.getFieldValue('leave_category')
  1111. if(leaveCategory=='年假' && !estimate){
  1112. this.$message.error('请填写预计请假天数!')
  1113. addForm = 'yes'
  1114. }
  1115. if(estimate>this.leave && leaveCategory=='年假'){
  1116. this.$message.error('预计请假年假'+estimate+'大于剩余年假'+this.leave)
  1117. addForm = 'yes'
  1118. }
  1119. }
  1120. if(this.processData.businessTable == 'incident_ticket'){
  1121. var sonTable=[]
  1122. // 获取子表数据
  1123. _.keys(formData1).forEach(r => {
  1124. if (r.indexOf('child&') != -1) {
  1125. sonTable=formData1[r]
  1126. }
  1127. })
  1128. if(sonTable!==''){
  1129. }
  1130. var supplier = this.$refs.KFB.form.getFieldValue('responsibility_company')
  1131. var responsibility1 = this.$refs.KFB.form.getFieldValue('responsibility_person1')
  1132. if(sonTable==''){
  1133. this.$message.error('计划单号未填写!')
  1134. addForm = 'yes'
  1135. }else{
  1136. var all = 0,
  1137. PlanNum=[]
  1138. sonTable.map(item=>{
  1139. item.accident_sum = item.accident_sum?item.accident_sum:'0'
  1140. all+= Number(item.accident_sum)
  1141. PlanNum.push(item.plan_number)
  1142. })
  1143. formData.total_money = all
  1144. formData.plan_number = PlanNum.toString()
  1145. sonTable.every(item=>{
  1146. if(item.accident_type=='不涉及金额' && item.accident_sum !=='0'){
  1147. this.$message.error('事故类型为不涉及金额时事故金额应为0!')
  1148. item.accident_sum = item.accident_sum
  1149. addForm = 'yes'
  1150. return false
  1151. }
  1152. return true
  1153. })
  1154. if((!supplier||supplier=='') && (!responsibility1 || responsibility1=='')){
  1155. this.$message.error('责任人和责任单位必填其一')
  1156. addForm = 'yes'
  1157. }
  1158. if(supplier&&supplier!==''){
  1159. var type = this.$refs.KFB.form.getFieldValue('business_type')
  1160. var factory = this.$refs.KFB.form.getFieldValue('factory_signature')
  1161. if(!type|| type==''){
  1162. this.$message.error('请选择业务类型')
  1163. // 边框变红
  1164. let div1 = document.getElementById('business_type')
  1165. div1.setAttribute('class', 'active')
  1166. addForm = 'yes'
  1167. }else if(!factory || factory==''){
  1168. sonTable.every(item=>{
  1169. if(item.accident_type=='扣款'){
  1170. this.$message.error('请上传工厂签章')
  1171. addForm = 'yes'
  1172. return false
  1173. }
  1174. return true
  1175. })
  1176. }
  1177. }
  1178. if(responsibility1&&responsibility1!==''){
  1179. var responsibility2 = this.$refs.KFB.form.getFieldValue('responsibility_person2')
  1180. var responsibility3 = this.$refs.KFB.form.getFieldValue('responsibility_person3')
  1181. var responsibility4 = this.$refs.KFB.form.getFieldValue('responsibility_person4')
  1182. var sum1 = this.$refs.KFB.form.getFieldValue('sum1')
  1183. var sum2 = this.$refs.KFB.form.getFieldValue('sum2')
  1184. var sum3 = this.$refs.KFB.form.getFieldValue('sum3')
  1185. var sum4 = this.$refs.KFB.form.getFieldValue('sum4')
  1186. var dd =[
  1187. {responsibility:responsibility1,sum:sum1,index:1},
  1188. {responsibility:responsibility2,sum:sum2,index:2},
  1189. {responsibility:responsibility3,sum:sum3,index:3},
  1190. {responsibility:responsibility4,sum:sum4,index:4},
  1191. ]
  1192. dd.every(item=>{
  1193. if((item.responsibility&&item.responsibility!=='') && (!item.sum|| item.sum=='')){
  1194. this.$message.error('请填写金额'+item.index)
  1195. addForm = 'yes'
  1196. return false
  1197. }
  1198. return true
  1199. })
  1200. }
  1201. }
  1202. }
  1203. // 处理手机端子表数据
  1204. if (this.isSJ) {
  1205. this.itemData(res)
  1206. }
  1207. // 清除为空的表单数据
  1208. _.keys(res).forEach(r => {
  1209. if (!res[r]) {
  1210. delete res[r]
  1211. }
  1212. })
  1213. console.log(formData)
  1214. formData.id = this.data.id
  1215. formData.procDefId = this.processData.id
  1216. formData.procDeTitle = this.processData.name
  1217. if (!formData.tableName) formData.tableName = this.processData.businessTable
  1218. formData.filedNames = _.keys(formData1).join(',')
  1219. formData.filedNames = getFiledNames(formData) // 获取主表字段,排除子表标识
  1220. var url = this.url.addApply
  1221. if (!this.isNew) {
  1222. url = this.url.editForm
  1223. }
  1224. // 是否存在子表
  1225. let ischild = false
  1226. // 循环表单字段属性判断是否属性中包含数组对象
  1227. let i = 0 // 子表数量
  1228. _.keys(res)
  1229. .join(',')
  1230. .split(',')
  1231. .forEach(element => {
  1232. if (formData[element] instanceof Array) {
  1233. // 判断是否符合子表命名规则
  1234. if (element.indexOf('&') != -1) {
  1235. let tableChildNameList = element.split('&')
  1236. // 判断是否能拆分两个字符,子表标识和子表数据库名称
  1237. if (tableChildNameList.length == 2) {
  1238. i++
  1239. let childName = tableChildNameList[1] // 子表数据库名称
  1240. if (!formData.table_name_children) {
  1241. // 第一次拼接
  1242. formData.table_name_children = childName // 表名
  1243. } else {
  1244. // 后面的表明拼接用“,”隔开
  1245. formData.table_name_children = formData.table_name_children + ',' + childName // 表名
  1246. }
  1247. // 定义属性名和值
  1248. formData['childFiledNames' + i] = _.keys(formData[element][0]).join(',') // 子表字段名
  1249. formData['childList' + i] = JSON.stringify(formData[element]) // 子表数据
  1250. ischild = true
  1251. }
  1252. } else {
  1253. // 如果不是子表则是上传文件,则转字符串
  1254. formData[element] = JSON.stringify(formData[element])
  1255. }
  1256. }
  1257. // formData[element];
  1258. })
  1259. // 判断需不需要存子表
  1260. if (ischild) {
  1261. formData.filedNames = formData.filedNames + ',table_name_children'
  1262. }
  1263. console.log(formData)
  1264. // 子表数据
  1265. // 调用保存接口
  1266. this.todoManageOperationObject.formData = formData
  1267. this.todoManageOperationObject.url = url
  1268. // formData.jsonContent=JSON.stringify(this.jsonData).toString()
  1269. // 获取是否部门负责人
  1270. formData.filedNames = formData.filedNames + ',is_leaders'
  1271. // formData.is_leaders = this.$store.getters.userInfo.identity
  1272. formData.is_leaders = this.$store.getters.userInfo.isPossess
  1273. // 清除子表规则的属性
  1274. _.keys(formData).forEach(r => {
  1275. if (r.indexOf('child&') != -1) {
  1276. delete formData[r]
  1277. }
  1278. })
  1279. // 如果手机端子表得则需要修改json
  1280. // var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
  1281. var jsonPamats = JSON.parse(JSON.stringify(this.jsonDataSave))
  1282. if (!this.isSJ && this.isNew) {
  1283. jsonPamats = null
  1284. }
  1285. this.todoManageOperationObject.jsonData = jsonPamats
  1286. // 非我的待办节点打卡表单界面
  1287. if(addForm=='no'){
  1288. this.btndisabled = true
  1289. postFormDataAction(url, formData, { jsonContent: jsonPamats })
  1290. .then(res => {
  1291. if (res.success) {
  1292. this.todoManageOperationObject.isSave = true
  1293. this.$message.success('保存成功!')
  1294. console.log('123')
  1295. this.$emit('afterSubmit', formData)
  1296. this.$emit('close')
  1297. // resolve(true);
  1298. } else {
  1299. this.$message.error(res.message)
  1300. // resolve(false);
  1301. }
  1302. })
  1303. .finally(() => {
  1304. this.btndisabled = false
  1305. // resolve(false);
  1306. })
  1307. }
  1308. })
  1309. .catch(err => {
  1310. console.log(err, '校验失败')
  1311. // resolve(false);
  1312. })
  1313. // })
  1314. },
  1315. // 我的待办点击通过保存专用
  1316. handleSubmit2 (e) {
  1317. // return new Promise((resolve)=>{
  1318. // 通过函数获取数据
  1319. this.$refs.KFB.getData()
  1320. .then(res => {
  1321. // 处理手机端子表数据
  1322. if (this.isSJ) {
  1323. this.itemData(res)
  1324. }
  1325. // 清除为空的表单数据
  1326. _.keys(res).forEach(r => {
  1327. if (!res[r]) {
  1328. delete res[r]
  1329. }
  1330. })
  1331. // 获取数据成功
  1332. let formData = JSON.parse(JSON.stringify(res))
  1333. console.log(formData)
  1334. formData.id = this.data.id
  1335. formData.procDefId = this.processData.id
  1336. formData.procDeTitle = this.processData.name
  1337. // formData.jsonContent=JSON.stringify(this.jsonData)
  1338. if (!formData.tableName) formData.tableName = this.processData.businessTable
  1339. formData.filedNames = _.keys(res).join(',')
  1340. formData.filedNames = getFiledNames(formData) // 获取主表字段,排除子表标识
  1341. var url = this.url.addApply
  1342. if (!this.isNew) {
  1343. url = this.url.editForm
  1344. }
  1345. // 是否存在子表
  1346. let ischild = false
  1347. // 循环表单字段属性判断是否属性中包含数组对象
  1348. let i = 0 // 子表数量
  1349. _.keys(res)
  1350. .join(',')
  1351. .split(',')
  1352. .forEach(element => {
  1353. if (formData[element] instanceof Array) {
  1354. // 判断是否符合子表命名规则
  1355. if (element.indexOf('&') != -1) {
  1356. let tableChildNameList = element.split('&')
  1357. // 判断是否能拆分两个字符,子表标识和子表数据库名称
  1358. if (tableChildNameList.length == 2) {
  1359. i++
  1360. let childName = tableChildNameList[1] // 子表数据库名称
  1361. if (!formData.table_name_children) {
  1362. // 第一次拼接
  1363. formData.table_name_children = childName // 表名
  1364. } else {
  1365. // 后面的表明拼接用“,”隔开
  1366. formData.table_name_children = formData.table_name_children + ',' + childName // 表名
  1367. }
  1368. // 定义属性名和值
  1369. formData['childFiledNames' + i] = _.keys(formData[element][0]).join(',') // 子表字段名
  1370. formData['childList' + i] = JSON.stringify(formData[element]) // 子表数据
  1371. ischild = true
  1372. }
  1373. } else {
  1374. // 如果不是子表则是上传文件,则转字符串
  1375. formData[element] = JSON.stringify(formData[element])
  1376. }
  1377. }
  1378. // formData[element];
  1379. })
  1380. // 判断需不需要存子表
  1381. if (ischild) {
  1382. formData.filedNames = formData.filedNames + ',table_name_children'
  1383. }
  1384. console.log(formData)
  1385. // 子表数据
  1386. // 调用保存接口
  1387. this.btndisabled = true
  1388. this.todoManageOperationObject.formData = formData
  1389. this.todoManageOperationObject.url = url
  1390. // 获取是否部门负责人
  1391. formData.filedNames = formData.filedNames + ',is_leaders'
  1392. // formData.is_leaders = this.$store.getters.userInfo.identity
  1393. formData.is_leaders = this.$store.getters.userInfo.isPossess
  1394. // 清除子表规则的属性
  1395. _.keys(formData).forEach(r => {
  1396. if (r.indexOf('child&') != -1) {
  1397. delete formData[r]
  1398. }
  1399. })
  1400. // 如果手机端子表得则需要修改json
  1401. // var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
  1402. var jsonPamats = JSON.parse(JSON.stringify(this.jsonDataSave))
  1403. if (!this.isSJ && this.isNew) {
  1404. jsonPamats = null
  1405. }
  1406. this.todoManageOperationObject.jsonData = jsonPamats
  1407. })
  1408. .catch(err => {
  1409. console.log(err, '校验失败')
  1410. // resolve(false);
  1411. })
  1412. // })
  1413. },
  1414. close () {
  1415. this.$emit('close')
  1416. },
  1417. getData () {
  1418. // 通过函数获取数据
  1419. this.$refs.KFB.getData()
  1420. .then(res => {
  1421. // 获取数据成功
  1422. alert(JSON.stringify(res))
  1423. })
  1424. .catch(err => {
  1425. console.log(err, '校验失败')
  1426. })
  1427. },
  1428. // 刷新待办列表
  1429. refreshToDo () {
  1430. this.close()
  1431. this.$emit('getDataList')
  1432. },
  1433. itemData (res) {
  1434. var childName = '' // 子表规则名称
  1435. var itemIndex = 0
  1436. this.jsonData.list.forEach((element, index) => {
  1437. if (element.label.indexOf('child&') != -1) {
  1438. childName = element.label // 获取规则名
  1439. itemIndex = itemIndex + 1
  1440. }
  1441. })
  1442. var itemList = [] // 封装子表数据
  1443. for (var i = 1; i <= itemIndex; i++) {
  1444. var itemObject = {} // 子表对象
  1445. this.itemModelNameList.forEach(name => {
  1446. // 获取子表得值和封装对象
  1447. itemObject[name] = res[name + '@' + i]
  1448. delete res[name + '@' + i]
  1449. })
  1450. itemList.push(itemObject)
  1451. }
  1452. res[childName] = itemList // 完成子表数据封装
  1453. console.log(res)
  1454. },
  1455. deleteRow (idIndex) {
  1456. // 删除
  1457. this.jsonData.list.splice(idIndex, 1)
  1458. // 删除掉得json之后 重新处理model 和value
  1459. let childIndex = 0
  1460. this.jsonData.list.forEach((element, index) => {
  1461. if (element.label.indexOf('child&') != -1) {
  1462. childIndex = childIndex + 1
  1463. // 只有当前删除的对象json的后面对象json才进行修改
  1464. if (index >= idIndex) {
  1465. // 修改删除按钮的index
  1466. element.columns[0].list[1].options.defaultValue =
  1467. '<a href="javascript:void(0);" \n onclick="deleteRow(' + childIndex + ')">删除</a>'
  1468. // 修改model
  1469. updateModel(element, childIndex)
  1470. // 需要调整的子表值
  1471. var updateModelObject = {}
  1472. // 修改value
  1473. this.$refs.KFB.getData().then(res => {
  1474. // 根据原始字段名拼接带规则的
  1475. this.itemModelNameList.forEach(modelName => {
  1476. updateModelObject[modelName + '@' + childIndex] = res[modelName + '@' + (childIndex + 1)]
  1477. })
  1478. this.$refs.KFB.setData(updateModelObject)
  1479. })
  1480. }
  1481. }
  1482. })
  1483. console.log(JSON.stringify(this.jsonData.list))
  1484. },
  1485. add () {
  1486. let childLable = '' // 子表json标题
  1487. let childValue = {} // 新增子表json
  1488. let isReturn = false
  1489. let childIndex = 0
  1490. var itemList = []
  1491. this.jsonData.list.forEach((element, index) => {
  1492. if (element.label.indexOf('child&') != -1) {
  1493. childValue = JSON.parse(JSON.stringify(element))
  1494. childLable = element.label
  1495. // 处理删除按钮
  1496. childIndex = childIndex + 1
  1497. // element.columns[0].list[1].options.dynamicFun = 'delete' + childIndex
  1498. console.log(element.columns[0].list[1].options)
  1499. element.columns[0].list[1].options.defaultValue =
  1500. '<a href="javascript:void(0);" \n onclick="deleteRow(' + childIndex + ')">删除</a>'
  1501. updateModel(childValue, childIndex)
  1502. }
  1503. if (!isReturn && childLable != '' && element.label != childLable) {
  1504. isReturn = true
  1505. // 处理删除按钮
  1506. childIndex = childIndex + 1
  1507. // childValue.columns[0].list[1].options.dynamicFun = 'delete' + childIndex
  1508. childValue.columns[0].list[1].options.defaultValue =
  1509. '<a href="javascript:void(0);" \n onclick="deleteRow(' + childIndex + ')">删除</a>'
  1510. updateModel(childValue, childIndex)
  1511. // this.jsonData.list.splice(index, 0, childValue)
  1512. itemList.push(childValue)
  1513. }
  1514. itemList.push(element)
  1515. })
  1516. this.jsonData.list = itemList
  1517. console.log(JSON.stringify(this.jsonData.list))
  1518. },
  1519. // 把整个子表json的model进行规则修改
  1520. async listUpdateModel () {
  1521. let modelIndex = 0 // 子表model自增
  1522. // 循环整个json的表单
  1523. this.jsonData.list.forEach((element, index) => {
  1524. // 找到为子表的json
  1525. if (element.label.indexOf('child&') != -1) {
  1526. this.isSJ = true
  1527. // 获取子表原始得model字段名
  1528. if (modelIndex == 0) {
  1529. var i = 1
  1530. var itemString = JSON.stringify(element)
  1531. var itemModelNameList = [] // 储存子表字段名
  1532. for (var i = 1; i !== -1;) {
  1533. // 动态字符位置
  1534. i = itemString.indexOf('"model"', i)
  1535. if (i !== -1) {
  1536. // 从指定字符的周后一个字符后开始找(")
  1537. var ihStart = itemString.indexOf('"', i + 7)
  1538. // 再从 (") 后面位置还是找下一个 (")
  1539. var ihEnd = itemString.indexOf('"', ihStart + 1)
  1540. // 获取引号之间的字符
  1541. var model = itemString.substring(ihStart + 1, ihEnd)
  1542. // 如果动态表示不为空则获取
  1543. if (model != '') {
  1544. if (model.indexOf('@') != -1) {
  1545. model = model.substring(0, model.length - 2)
  1546. }
  1547. itemModelNameList.push(model)
  1548. }
  1549. i = ihEnd + 1
  1550. }
  1551. }
  1552. this.itemModelNameList = itemModelNameList
  1553. }
  1554. modelIndex = modelIndex + 1
  1555. // 修改model
  1556. updateModel(element, modelIndex)
  1557. }
  1558. })
  1559. },
  1560. //计算时间差
  1561. timeDifference(start, end,state){
  1562. if(getProjctName() =='技能博物馆'){
  1563. var startDayArr = start.split(' '),
  1564. startDay = startDayArr[0]+' '+'16:00'
  1565. // 计算出请假第一天距离下班多久
  1566. var s1 = new Date(start.replace(/-/g, '/')),
  1567. s2 = new Date(startDay.replace(/-/g, '/')),
  1568. ms = Math.abs(s1.getTime() - s2.getTime()),
  1569. mins= (ms / 1000 / 60 / 60);
  1570. // ___________
  1571. var endDayArr = end.split(' '),
  1572. endDay = endDayArr[0]+' '+'9:00'
  1573. // 计算出请假最后一天距离上班多久
  1574. var s11 = new Date(end.replace(/-/g, '/')),
  1575. s22 = new Date(endDay.replace(/-/g, '/')),
  1576. ms2 = Math.abs(s11.getTime() - s22.getTime()),
  1577. mins2= (ms2 / 1000 / 60 / 60);
  1578. // ————————
  1579. var startDay = new Date(start),
  1580. endDay = new Date(end),
  1581. startDateTime=new Date(startDay.setDate(startDay.getDate()+1));
  1582. startDateTime =(moment(startDateTime).format('YYYY-MM-DD HH:mm')).split(' ')
  1583. var EndDateTime=new Date(endDay.setDate(endDay.getDate()-1));
  1584. EndDateTime =(moment(EndDateTime).format('YYYY-MM-DD HH:mm')).split(' ')
  1585. var myDate_1 = Date.parse(EndDateTime[0]),
  1586. myDate_2 = Date.parse(startDateTime[0])
  1587. //计算除去第一天和最后一天后相差多少天
  1588. var diffDate = Math.abs(myDate_1 - myDate_2), // 取相差毫秒数的绝对值
  1589. totalDays = Math.floor(diffDate / (1000 * 3600 * 24))+1 // 向下取整
  1590. if(startDateTime>EndDateTime){
  1591. totalDays = 0
  1592. }
  1593. var dayTime = (totalDays+(mins+mins2)/8).toFixed(1)
  1594. return dayTime
  1595. }else{
  1596. // if(start>end){
  1597. // this.$message.error('起始时间不可大于结束时间');
  1598. // }else{
  1599. let beginTime = (new Date(start).getTime()) / 1000;
  1600. let endTime = (new Date(end).getTime()) / 1000;
  1601. //计算天数
  1602. var timediff = endTime - beginTime;
  1603. var days = parseInt(timediff / 86400); //60*60*24
  1604. //计算小时数
  1605. var remain = timediff % 86400 ;
  1606. var hours = parseInt(remain / 3600);
  1607. //计算分钟数
  1608. var remain = remain % 3600;
  1609. var mins = parseInt(remain / 60);
  1610. var res = days + '天' + hours + '小时' + mins + '分';
  1611. if(state == 'min'){
  1612. return days*24*60+hours*60+mins
  1613. }else if(state == 'hour'){
  1614. return days*24+hours+mins/60
  1615. }else if(state == 'day'){
  1616. if(start.split(' ').length==1 && end.split(' ').length == 1){
  1617. return days+1+hours/24+mins/60/24
  1618. }else{
  1619. return days+hours/24+mins/60/24
  1620. }
  1621. }else if(state == 'day/hour/min'){
  1622. return days+'天'+hours+'小时'+mins+'分'
  1623. }else if(state == 'hour/min'){
  1624. return (days*24+hours)+'小时'+mins+'分'
  1625. }
  1626. }
  1627. }
  1628. }
  1629. // }
  1630. }
  1631. // 获取主表字段,排除子表标识
  1632. function getFiledNames (formData) {
  1633. let filedNames = ''
  1634. let list = formData.filedNames.split(',') // 获取表单属性名集合
  1635. list.forEach(element => {
  1636. if (element.indexOf('&') == -1) {
  1637. // 查询是否有这个字段
  1638. if (filedNames == '') {
  1639. // 第一次则直接等于
  1640. filedNames = element
  1641. } else {
  1642. // 后面用逗号隔开
  1643. filedNames = filedNames + ',' + element
  1644. }
  1645. }
  1646. })
  1647. return filedNames
  1648. }
  1649. // 根据开始时间 结束时间计算天数
  1650. function startEndFun (start, end) {
  1651. let startTime = new Date(start)
  1652. let endTime = new Date(end)
  1653. if (startTime >= endTime) {
  1654. return 0
  1655. }
  1656. // 1,分钟取整
  1657. startTime = carryTime(startTime)
  1658. endTime = carryTime(endTime)
  1659. // 2,计算总天数
  1660. var totalTime = 0 // 工时,天数
  1661. if (startTime.getDay() == 6 || startTime.getDay() == 0) {
  1662. totalTime = endTime.getDate() - startTime.getDate()
  1663. } else {
  1664. totalTime = Math.floor((endTime - startTime) / (3600 * 1000) / 24)
  1665. }
  1666. // 3,拿初始值赋值给一个临时变量
  1667. var tempStartTime = new Date()
  1668. tempStartTime.setTime(startTime.getTime())
  1669. // 4,计算出总天数
  1670. while (tempStartTime.getDate() < endTime.getDate()) {
  1671. if (tempStartTime.getDay() == 6 || tempStartTime.getDay() == 0) {
  1672. // 周六或者周日减去
  1673. totalTime--
  1674. }
  1675. tempStartTime.setDate(tempStartTime.getDate() + 1)
  1676. }
  1677. // 5,计算出总小时数
  1678. var temp = 0 // 工时,小时
  1679. do {
  1680. if (startTime.getDay() == 6 || startTime.getDay() == 0) {
  1681. // 周六周日
  1682. startTime.setDate(startTime.getDate() + 1)
  1683. //* ********周六周日直接跳过,初始化为早晨9点
  1684. startTime.setHours(9)
  1685. startTime.setMinutes(0)
  1686. continue
  1687. }
  1688. if (endTime.getDay() == 6 || endTime.getDay() == 0) {
  1689. // 周六周日
  1690. endTime.setDate(endTime.getDate() + 1)
  1691. //* ********周六周日直接跳过,初始化为早晨9点
  1692. endTime.setHours(9)
  1693. endTime.setMinutes(0)
  1694. continue
  1695. }
  1696. let tempMinutes = startTime.getHours() * 60 + startTime.getMinutes()
  1697. // 上午9点到12点半,算工时
  1698. if (tempMinutes >= 9 * 60 && tempMinutes < 12 * 60) {
  1699. temp += 0.05
  1700. }
  1701. // 上午14点到18点半,算工时
  1702. if (tempMinutes >= 13 * 60 && tempMinutes < 18 * 60) {
  1703. temp += 0.05
  1704. }
  1705. startTime.setTime(startTime.getTime() + 0.5 * 3600 * 1000) // 每次增加半个小时
  1706. } while (startTime.getHours() * 60 + startTime.getMinutes() != endTime.getHours() * 60 + endTime.getMinutes())
  1707. {
  1708. totalTime += Math.floor(temp / 0.8)
  1709. totalTime += temp % 0.8
  1710. totalTime = Math.round(totalTime * 100) / 100
  1711. }
  1712. var days = Math.floor(totalTime)
  1713. var hours = Math.round((totalTime - days) * 100) / 10
  1714. console.log(days + '天', hours + '小时')
  1715. return days * 8 + hours
  1716. // if (start && end) {
  1717. // let startTime = new Date(start) // 开始时间
  1718. // let endTime = new Date(end) // 结束时间
  1719. // let usedTime = endTime - startTime // 相差的毫秒数
  1720. // let days = (usedTime / 1000 / 60 / 60).toFixed(2) // 计算出天数
  1721. // return days
  1722. // } else {
  1723. // return null
  1724. // }
  1725. }
  1726. // 格式化时间
  1727. function formatDate (date, fmt) {
  1728. if (/(y+)/.test(fmt)) {
  1729. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
  1730. }
  1731. let o = {
  1732. 'M+': date.getMonth() + 1,
  1733. 'd+': date.getDate(),
  1734. 'h+': date.getHours(),
  1735. 'm+': date.getMinutes(),
  1736. 's+': date.getSeconds()
  1737. }
  1738. for (let k in o) {
  1739. if (new RegExp(`(${k})`).test(fmt)) {
  1740. let str = o[k] + ''
  1741. fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : padLeftZero(str))
  1742. }
  1743. }
  1744. return fmt
  1745. }
  1746. function padLeftZero (str) {
  1747. return ('00' + str).substr(str.length)
  1748. }
  1749. /*
  1750. * 0-15分不算工时
  1751. * 15-45算半个小时
  1752. * 45-60算一个小时
  1753. * */
  1754. function carryTime (date) {
  1755. if (date.getMinutes() > 0 && date.getMinutes() < 15) {
  1756. date.setMinutes(0)
  1757. }
  1758. if (date.getMinutes() >= 15 && date.getMinutes() < 30) {
  1759. date.setMinutes(30)
  1760. }
  1761. if (date.getMinutes() > 30 && date.getMinutes() < 45) {
  1762. date.setMinutes(30)
  1763. }
  1764. if (date.getMinutes() >= 45) {
  1765. date.setHours(date.getHours() + 1)
  1766. date.setMinutes(0)
  1767. }
  1768. return date
  1769. }
  1770. // function
  1771. /**
  1772. * 修改model绑定值
  1773. */
  1774. function updateModel (object, childIndex) {
  1775. let keyString = _.keys(object).join(',')
  1776. if (keyString.indexOf('model') != -1) {
  1777. // 如果没有修改过则直接修改
  1778. if (object['model'].indexOf('@') == -1) {
  1779. object['model'] = object['model'] + '@' + childIndex
  1780. } else {
  1781. // 修改过则截取修改前的再进行修改
  1782. var m = object['model'].substring(0, object['model'].length - 2)
  1783. object['model'] = m + '@' + childIndex
  1784. }
  1785. }
  1786. // 递归
  1787. _.keys(object)
  1788. .join(',')
  1789. .split(',')
  1790. .forEach(l => {
  1791. if (object[l] instanceof Array) {
  1792. object[l].forEach(element => {
  1793. updateModel(element, childIndex)
  1794. })
  1795. }
  1796. })
  1797. }
  1798. </script>
  1799. <style lang="less" scoped>
  1800. @media print {
  1801. @page {
  1802. /* 横向 */
  1803. size: landscape;
  1804. /* 去除浏览器默认页眉页脚 */
  1805. margin: 0;
  1806. }
  1807. * {
  1808. -webkit-print-color-adjust: exact !important; /* Chrome, Safari */
  1809. color-adjust: exact !important; /*Firefox*/
  1810. }
  1811. .noprint {
  1812. display: none;
  1813. }
  1814. /deep/ .ant-select-selection--multiple .ant-select-selection__rendered>ul>li, .ant-select-selection--multiple>ul>li{
  1815. font-size: 14px!important;
  1816. border: 0px solid black!important;
  1817. min-width: 150px!important;
  1818. height: 25!important;
  1819. }
  1820. /deep/ .ant-select-selection__choice__remove{
  1821. display: none;
  1822. }
  1823. // /deep/.ant-input{
  1824. // border: none !important;
  1825. // }
  1826. // /deep/ .ant-modal-header{
  1827. // display: none !important;
  1828. // }
  1829. // /deep/ .ant-modal-content{
  1830. // box-shadow:none !important
  1831. // }
  1832. /deep/ * {
  1833. color: #000000!important;
  1834. -webkit-tap-highlight-color: #000000!important;
  1835. }
  1836. /*update_end author:scott date:20191203 for:打印机打印的字体模糊问题 */
  1837. /deep/ .abcdefg .ant-card-body{
  1838. margin-left: 0%;
  1839. margin-right: 0%;
  1840. margin-bottom: 1%;
  1841. border:0px solid black;
  1842. min-width: 800px;
  1843. color:#000000!important;
  1844. }
  1845. /deep/ .explain{
  1846. text-align: left;
  1847. margin-left: 50px;
  1848. color:#000000!important;
  1849. }
  1850. /deep/ .explain .ant-input,.sign .ant-input{
  1851. font-weight:bolder;
  1852. text-align:center;
  1853. border-left-width:0px!important;
  1854. border-top-width:0px!important;
  1855. border-right-width:0px!important;
  1856. }
  1857. /deep/ .explain div{
  1858. margin-bottom: 10px;
  1859. }
  1860. /* you can make up upload button and sample style by using stylesheets */
  1861. /deep/ .ant-upload-select-picture-card i {
  1862. font-size: 32px;
  1863. color: #999;
  1864. }
  1865. /deep/ .ant-upload-select-picture-card .ant-upload-text {
  1866. margin-top: 8px;
  1867. color: #666;
  1868. }
  1869. }
  1870. /deep/ .anticon-question-circle-o {
  1871. display: none !important;
  1872. }
  1873. /deep/ textarea#presentation_condition {
  1874. height: 290px;
  1875. }
  1876. /deep/ textarea#meeting_content {
  1877. height: 290px;
  1878. }
  1879. /deep/ .active .ant-select-selection {
  1880. border: 1px solid red;
  1881. }
  1882. </style>