demoForm2.vue 91 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000
  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 == '业务需求报销' || 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 !== '公司采购'){ //公司采购,不显示签名
  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
  743. // if(that.processData.businessTable == 'expense_account'){//报销单-自动生成单号
  744. // if( that.processData.tableId==''|| !that.processData.tableId){
  745. // that.getAction('/sys/user/getNextNo',{name:'BXDCode'}).then(res => {
  746. // that.$refs.KFB.setData({reimbursement_no:res})
  747. // })
  748. // }
  749. // }
  750. },200)
  751. }
  752. },
  753. // 获取申请人信息
  754. getApplicant () {
  755. console.log('aa', this.$refs.KFB.form.getFieldValue('applicant'))
  756. // if (this.$refs.KFB.form.getFieldValue('applicant')) {
  757. // alert(1)
  758. // this.$refs.KFB.setData({
  759. // applicant: this.$store.getters.userInfo.username
  760. // })
  761. // }
  762. },
  763. changedd(){
  764. window.print()
  765. },
  766. //主子表计算
  767. tableCalculation(value){
  768. if(this.processData.businessTable == 'supplieses_apply_a' ){
  769. var number1 = 0,
  770. number2 = 0
  771. //寻找help信息中对应的modol值
  772. this.bv.map(item=>{
  773. this.cvarr.map(vv=>{
  774. if(vv.key == item.bn[1].label){
  775. number1 = vv.model
  776. }else if(vv.key == item.bn[2].label){
  777. number2 = vv.model
  778. }
  779. })
  780. //表中每一行分别计算
  781. var sum = 0
  782. value.map(b=>{
  783. b[item.bn[0].label] = (b[number1]*b[number2]).toFixed(2)
  784. sum += b[number1]*b[number2] //计算出表格内的总价总和
  785. if(this.$store.getters.nickname=='崔崇杰'){
  786. b['procurement_type']='公司采购'
  787. }else if(b['procurement_type']=='' ||!b['procurement_type'] ){
  788. b['procurement_type']='部门采购'
  789. }
  790. })
  791. sum = sum.toFixed(2)
  792. this.$refs.KFB.setData({sum:sum})
  793. })
  794. }
  795. if(this.processData.businessTable == 'incident_ticket'){
  796. var all = 0,
  797. currencys=[],
  798. currency =''
  799. value.map(item=>{
  800. item.accident_sum = item.accident_sum?item.accident_sum:'0'
  801. //计算表头总价
  802. all+=Number(item.accident_sum)
  803. //币种-自动带出
  804. if(item.money_type){currencys.push(item.money_type)}
  805. })
  806. //获取表格中只出现一次的币种-即为改变的币种
  807. currencys.every(item=>{
  808. const countOccurences = (arr, value) => arr.reduce((a, v) => v === value ? a + 1 : a + 0, 0)
  809. if(countOccurences(currencys,item)==1){
  810. currency=item
  811. return false
  812. }
  813. return true
  814. })
  815. //赋值
  816. value.map(item=>{
  817. //若无只出现一次的币种 1.第一次表格增行 2.表格中有两条以上数据,再次增行
  818. if(currency==''){
  819. item.money_type = currencys[0]
  820. }else{
  821. item.money_type = currency
  822. }
  823. })
  824. this.$refs.KFB.setData({total_money:all})
  825. }
  826. },
  827. specialTerms(value,key){
  828. var that = this
  829. //剩余年假
  830. if(key == 'employe_name'){
  831. setTimeout(function(){
  832. annualLeave({username:value}).then(res => {
  833. if (res.success) {
  834. //选择姓名获取页面的请假类型和时间间隔
  835. that.leave = res.result.nannualNowNum
  836. that.$refs.KFB.setData({leave_remaining: that.leave})
  837. var category = that.$refs.KFB.form.getFieldValue('leave_category')
  838. var time1 = that.$refs.KFB.form.getFieldValue('start_date')
  839. var time2 = that.$refs.KFB.form.getFieldValue('end_date')
  840. var timeC=that.timeDifference(time1,time2,'min') //获取时间差
  841. //事假,超过180分钟,年假大于0.5
  842. if(category == '事假' &&timeC>=180&&that.leave>=0.5){
  843. that.$refs.KFB.setData({unit:'天'})
  844. that.$refs.KFB.setData({leave_category:'年假'})
  845. }else if(category == '年假' && that.leave<0.5){ //类型为年假,剩余年假小于0.5
  846. that.$refs.KFB.setData({unit:'分'})
  847. that.$refs.KFB.setData({leave_category:''})
  848. that.$message.error('剩余年假不足!');
  849. }
  850. }else{
  851. that.$message.error(res.message);
  852. }
  853. })
  854. },0)
  855. }
  856. //请假类型与单位
  857. //事假
  858. if(key == 'leave_category' && value == '事假'){
  859. setTimeout(function(){
  860. var time1 = that.$refs.KFB.form.getFieldValue('start_date')
  861. var time2 = that.$refs.KFB.form.getFieldValue('end_date')
  862. var timeC=that.timeDifference(time1,time2,'min') //获取时间差
  863. if(timeC>=180 && that.leave>=0.5){ //事假,时间差大于180,剩余年假大于0.5
  864. that.$refs.KFB.setData({unit:'天'})
  865. that.$refs.KFB.setData({leave_category:'年假'})
  866. }else{
  867. that.$refs.KFB.setData({unit:'分'})
  868. }
  869. },0)
  870. }else if(key == 'leave_category' && value == '病假'){ //病假
  871. setTimeout(function(){
  872. that.$refs.KFB.setData({unit:'分'})
  873. },0)
  874. }else if(key == 'leave_category' && value == '年假'){//年假
  875. setTimeout(function(){
  876. if(that.leave >=0.5){ //剩余年假大于0.5
  877. that.$refs.KFB.setData({unit:'天'})
  878. }else{ //剩余年假小于0.5
  879. that.$refs.KFB.setData({unit:'分'})
  880. that.$refs.KFB.setData({leave_category:''})
  881. that.$message.error('剩余年假不足!');
  882. }
  883. },0)
  884. }else if(key == 'leave_category'){
  885. setTimeout(function(){
  886. that.$refs.KFB.setData({unit:'天'})
  887. },0)
  888. }
  889. //时间间隔和类型
  890. if(key =='start_date' || key =='end_date'){
  891. setTimeout(function(){
  892. var time2 = that.$refs.KFB.form.getFieldValue('end_date')
  893. var time1 = that.$refs.KFB.form.getFieldValue('start_date')
  894. var timeC=that.timeDifference(time1,time2,'min')
  895. var lx=that.$refs.KFB.form.getFieldValue('leave_category')
  896. if(timeC>=180&&lx=='事假'&&that.leave>=0.5){ //事假,时间差大于180,剩余年假大于0.5
  897. that.$refs.KFB.setData({unit:'天'})
  898. that.$refs.KFB.setData({leave_category:'年假'})
  899. }
  900. },0)
  901. }
  902. },
  903. // 表单字段数值发生改变事件
  904. handleChange (value, key) {
  905. // debugger
  906. if(key == 'proposer' && this.processData.businessTable == 'regular_employee_apply'){//员工转正申请:申请人部门
  907. this.$refs.KFB.setData({apply_department:this.deptInfo[value]})
  908. }
  909. if(key == 'regular_employee' && this.processData.businessTable == 'regular_employee_apply'){//员工转正申请:转正人员岗位
  910. this.$refs.KFB.setData({job_title:this.postInfo[value]})
  911. }
  912. if(key == 'proposer' && this.processData.businessTable == 'seal_apply'){//用印申请单
  913. this.$refs.KFB.setData({apply_department:this.deptInfo[value]})
  914. }
  915. if(key == 'employee_name' && this.processData.businessTable == 'separation_application'){//离职申请
  916. this.$refs.KFB.setData({job_title:this.postInfo[value]})
  917. }
  918. //森语-质量事故单
  919. if(key=='child&incident_ticket_children'){
  920. this.tableCalculation(value)
  921. }
  922. //技能博物馆-----退休录入
  923. if(key == 'name' && this.processData.businessTable == 'bwg_retire_input'){//技能博物馆 ---- 退休录入
  924. this.dynamicData.personListJn.map(item =>{
  925. if(item.label == value){
  926. this.$refs.KFB.setData({employee_number:item.workNo})
  927. this.$refs.KFB.setData({post:item.post})
  928. this.$refs.KFB.setData({rz_date:item.nInductionTim})
  929. }
  930. })
  931. // this.$refs.KFB.setData({employee_number:this.postInfo[value]})
  932. }
  933. //技能博物馆-----离职录入
  934. if(key == 'name' && this.processData.businessTable == 'bwg_quit_input'){//技能博物馆 ---- 退休录入
  935. this.dynamicData.personListJn.map(item =>{
  936. if(item.label == value){
  937. this.$refs.KFB.setData({employee_number:item.workNo})
  938. this.$refs.KFB.setData({post:item.post})
  939. this.$refs.KFB.setData({rz_date:item.nInductionTim})
  940. }
  941. })
  942. }
  943. //技能博物馆 ----- 费用报销
  944. if(key == 'expense_person' && this.processData.businessTable == 'bwg_expense_apply'){
  945. this.dynamicData.personListJn.map(item =>{
  946. if(item.label == value){
  947. this.$refs.KFB.setData({expense_department:item.departIds_dictText})
  948. }
  949. })
  950. }
  951. // 技能博物馆---用车申请
  952. if(key == 'car_automobilist' && this.processData.businessTable == 'car_apply'){
  953. this.dynamicData.personListJn.map(item =>{
  954. if(item.label == value){
  955. this.$refs.KFB.setData({car_department:item.departIds_dictText})
  956. }
  957. })
  958. }
  959. // // 技能博物馆---物料库存--金额计算
  960. // if((key == 'unit_price'||key=='amount') && this.processData.businessTable == 'material_apply'){
  961. // var that = this
  962. // setTimeout(function(){
  963. // var unit_price = that.$refs.KFB.form.getFieldValue('unit_price'),
  964. // amount = that.$refs.KFB.form.getFieldValue('amount'),
  965. // sum = Number(unit_price)*Number(amount)
  966. // that.$refs.KFB.setData({money:sum})
  967. // },0)
  968. // }
  969. // 技能博物馆---物料库存--部门
  970. if(key == 'input_account' && this.processData.businessTable == 'material_apply'){
  971. this.dynamicData.personListJn.map(item =>{
  972. if(item.label == value){
  973. this.$refs.KFB.setData({department:item.departIds_dictText})
  974. }
  975. })
  976. }
  977. if(key == 'task_executor' &&this.processData.businessTable == 'task_management'){
  978. this.dynamicData.personListJn.map(item =>{
  979. if(item.label == value){
  980. this.$refs.KFB.setData({task_department:item.departIds_dictText})
  981. }
  982. })
  983. }
  984. // 技能博物馆---物料申领--部门
  985. if(key == 'get_account' && this.processData.businessTable == 'application_form'){
  986. this.dynamicData.personListJn.map(item =>{
  987. if(item.label == value){
  988. this.$refs.KFB.setData({department:item.departIds_dictText})
  989. }
  990. })
  991. }
  992. // 技能博物馆---固定资产--归还
  993. if(key == 'uuse_personnel' && this.processData.businessTable == 'give_back'){
  994. this.dynamicData.personListJn.map(item =>{
  995. if(item.label == value){
  996. this.$refs.KFB.setData({use_department:item.departIds_dictText})
  997. }
  998. })
  999. }
  1000. //技能博物馆-固定资产-报废
  1001. if(key == 'apply_personnel' &&this.processData.businessTable == 'scrap_apply'){
  1002. this.dynamicData.personListJn.map(item =>{
  1003. if(item.label == value){
  1004. this.$refs.KFB.setData({apply_personnel_department:item.departIds_dictText})
  1005. }
  1006. })
  1007. }
  1008. //技能博物馆 ----资金审批
  1009. if(key == 'project_name' && this.processData.businessTable == 'bwg_capital_approval'){
  1010. this.dynamicData.fundApproval.map(item =>{
  1011. if(item.label == value){
  1012. this.$refs.KFB.setData({start_data:item.startDate})
  1013. this.$refs.KFB.setData({end_date:item.endDate})
  1014. this.$refs.KFB.setData({project_reasons:item.projectReasons})
  1015. this.$refs.KFB.setData({budget_information:item.budgetInformation})
  1016. }
  1017. })
  1018. }
  1019. //改变的表单是主子表类型时----物质申请单
  1020. if(key =='child&supplieses_apply'){
  1021. this.tableCalculation(value)
  1022. }
  1023. //特别字段
  1024. this.specialTerms(value,key)
  1025. //代码赘余,日后维护
  1026. //保存发生改变字段名对应的key
  1027. var cc ='',
  1028. type = ''
  1029. this.cvarr.map(k =>{
  1030. if(k.model ==key){
  1031. cc=k.key
  1032. type = k.type
  1033. }})
  1034. //根据数值改变计算
  1035. var that =this
  1036. setTimeout(function(){
  1037. that.bv.map(event =>{
  1038. if(event.bn[1].label == cc || event.bn[2].label == cc){
  1039. that.cvarr.map(k=>{
  1040. if(k.key == event.bn[1].label){
  1041. event.bn[1].value = that.$refs.KFB.form.getFieldValue(k.model)
  1042. }else if(k.key == event.bn[2].label){
  1043. event.bn[2].value = that.$refs.KFB.form.getFieldValue(k.model)
  1044. }
  1045. })
  1046. if(type == 'date'){
  1047. if(event.bn[1].value!=='' && event.bn[2].value!==''){
  1048. var state = ''
  1049. state = event.bn[3].label
  1050. event.bn[0].value = that.timeDifference(event.bn[1].value,event.bn[2].value,state)
  1051. }
  1052. }else{
  1053. 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. }else if(event.bn[3].label =="*"){
  1058. event.bn[0].value = Number(event.bn[1].value)*Number(event.bn[2].value)
  1059. }
  1060. }
  1061. that.$refs.KFB.setData({[event.bn[0].label]:event.bn[0].value})
  1062. }
  1063. })
  1064. },0)
  1065. // // 数据变化时触发
  1066. // // 如果开始时间发生变化
  1067. // if (key == 'start_time') {
  1068. // // 判断结束时间是否存在
  1069. // if (this.$refs.KFB.form.getFieldValue('end_time')) {
  1070. // // 获取时间差
  1071. // let duration = startEndFun(value, this.$refs.KFB.form.getFieldValue('end_time'))
  1072. // if (duration) {
  1073. // // 使用k-form-design组件的form属性修改表单数据
  1074. // this.$refs.KFB.setData({
  1075. // duration: duration
  1076. // })
  1077. // }
  1078. // }
  1079. // }
  1080. // // 如果结束时间发生变化
  1081. // if (key == 'end_time') {
  1082. // // 判断结束时间是否存在
  1083. // if (this.$refs.KFB.form.getFieldValue('start_time')) {
  1084. // // 获取时间差
  1085. // let duration = startEndFun(this.$refs.KFB.form.getFieldValue('start_time'), value)
  1086. // if (duration) {
  1087. // // 使用k-form-design组件的form属性修改表单数据
  1088. // this.$refs.KFB.setData({
  1089. // duration: duration
  1090. // })
  1091. // }
  1092. // }
  1093. // }
  1094. },
  1095. // handler
  1096. handleSubmit (e) {
  1097. var that =this
  1098. // return new Promise((resolve)=>{
  1099. // 通过函数获取数据
  1100. this.$refs.KFB.getData()
  1101. .then(async(res) => {
  1102. // let formData1 = JSON.parse(JSON.stringify(res))
  1103. // // 获取数据成功
  1104. // let formData = JSON.parse(JSON.stringify(res))
  1105. let formData1 = JSON.parse(JSON.stringify(res, (key, value) => typeof value === 'undefined' ? '' : value))
  1106. // 获取数据成功
  1107. let formData = JSON.parse(JSON.stringify(res, (key, value) => typeof value === 'undefined' ? '' : value))
  1108. var addForm = 'no'
  1109. if(this.processData.businessTable == 'employee_leave'){
  1110. var estimate = this.$refs.KFB.form.getFieldValue('leave_days'),
  1111. // actual = that.$refs.KFB.form.getFieldValue('practical_leave'),
  1112. leaveCategory = this.$refs.KFB.form.getFieldValue('leave_category')
  1113. if(leaveCategory=='年假' && !estimate){
  1114. this.$message.error('请填写预计请假天数!')
  1115. addForm = 'yes'
  1116. }
  1117. if(estimate>this.leave && leaveCategory=='年假'){
  1118. this.$message.error('预计请假年假'+estimate+'大于剩余年假'+this.leave)
  1119. addForm = 'yes'
  1120. }
  1121. }
  1122. if(this.processData.businessTable == 'incident_ticket'){
  1123. var sonTable=[]
  1124. // 获取子表数据
  1125. _.keys(formData1).forEach(r => {
  1126. if (r.indexOf('child&') != -1) {
  1127. sonTable=formData1[r]
  1128. }
  1129. })
  1130. if(sonTable!==''){
  1131. }
  1132. var supplier = this.$refs.KFB.form.getFieldValue('responsibility_company')
  1133. var responsibility1 = this.$refs.KFB.form.getFieldValue('responsibility_person1')
  1134. var factory = this.$refs.KFB.form.getFieldValue('factory_signature')
  1135. _.keys(factory).forEach(r => {
  1136. let endName = factory[r].name;
  1137. if(!endName.endsWith('.png') && !endName.endsWith('.jpg') && !endName.endsWith('.jpeg')){
  1138. this.$message.error('工厂签章只能上传图片(png、jpg、jpeg格式)!')
  1139. addForm = 'yes'
  1140. return false
  1141. }
  1142. })
  1143. if(sonTable==''){
  1144. this.$message.error('计划单号未填写!')
  1145. addForm = 'yes'
  1146. }else{
  1147. var all = 0,
  1148. PlanNum=[]
  1149. sonTable.map(item=>{
  1150. item.accident_sum = item.accident_sum?item.accident_sum:'0'
  1151. all+= Number(item.accident_sum)
  1152. PlanNum.push(item.plan_number)
  1153. })
  1154. formData.total_money = Number(all).toFixed(2)
  1155. formData.plan_number = PlanNum.toString()
  1156. sonTable.every(item=>{
  1157. if(item.accident_type=='不涉及金额' && item.accident_sum !=='0'){
  1158. this.$message.error('事故类型为不涉及金额时事故金额应为0!')
  1159. item.accident_sum = item.accident_sum
  1160. addForm = 'yes'
  1161. return false
  1162. }
  1163. return true
  1164. })
  1165. if((!supplier||supplier=='') && (!responsibility1 || responsibility1=='')){
  1166. this.$message.error('责任人和责任单位必填其一')
  1167. addForm = 'yes'
  1168. }
  1169. if(supplier&&supplier!==''){
  1170. var type = this.$refs.KFB.form.getFieldValue('business_type')
  1171. var factory = this.$refs.KFB.form.getFieldValue('factory_signature')
  1172. if(!type|| type==''){
  1173. this.$message.error('请选择业务类型')
  1174. // 边框变红
  1175. let div1 = document.getElementById('business_type')
  1176. div1.setAttribute('class', 'active')
  1177. addForm = 'yes'
  1178. }else if(!factory || factory==''){
  1179. sonTable.every(item=>{
  1180. if(item.accident_type=='扣款'){
  1181. this.$message.error('请上传工厂签章')
  1182. addForm = 'yes'
  1183. return false
  1184. }
  1185. return true
  1186. })
  1187. }
  1188. }
  1189. if(responsibility1&&responsibility1!==''){
  1190. var responsibility2 = this.$refs.KFB.form.getFieldValue('responsibility_person2')
  1191. var responsibility3 = this.$refs.KFB.form.getFieldValue('responsibility_person3')
  1192. var responsibility4 = this.$refs.KFB.form.getFieldValue('responsibility_person4')
  1193. var sum1 = this.$refs.KFB.form.getFieldValue('sum1')
  1194. var sum2 = this.$refs.KFB.form.getFieldValue('sum2')
  1195. var sum3 = this.$refs.KFB.form.getFieldValue('sum3')
  1196. var sum4 = this.$refs.KFB.form.getFieldValue('sum4')
  1197. var dd =[
  1198. {responsibility:responsibility1,sum:sum1,index:1},
  1199. {responsibility:responsibility2,sum:sum2,index:2},
  1200. {responsibility:responsibility3,sum:sum3,index:3},
  1201. {responsibility:responsibility4,sum:sum4,index:4},
  1202. ]
  1203. dd.every(item=>{
  1204. if( ((item.responsibility&&item.responsibility!=='') &&(item.sum===''||item.sum== undefined ||item.sum== null ))){
  1205. this.$message.error('请填写金额'+item.index)
  1206. addForm = 'yes'
  1207. return false
  1208. }
  1209. return true
  1210. })
  1211. }
  1212. }
  1213. }
  1214. // 处理手机端子表数据
  1215. if (this.isSJ) {
  1216. this.itemData(res)
  1217. }
  1218. // 清除为空的表单数据
  1219. _.keys(res).forEach(r => {
  1220. if (!res[r]) {
  1221. delete res[r]
  1222. }
  1223. })
  1224. console.log(formData)
  1225. formData.id = this.data.id
  1226. formData.procDefId = this.processData.id
  1227. formData.procDeTitle = this.processData.name
  1228. if (!formData.tableName) formData.tableName = this.processData.businessTable
  1229. formData.filedNames = _.keys(formData1).join(',')
  1230. formData.filedNames = getFiledNames(formData) // 获取主表字段,排除子表标识
  1231. var url = this.url.addApply
  1232. if (!this.isNew) {
  1233. url = this.url.editForm
  1234. }
  1235. // 是否存在子表
  1236. let ischild = false
  1237. // 循环表单字段属性判断是否属性中包含数组对象
  1238. let i = 0 // 子表数量
  1239. _.keys(res)
  1240. .join(',')
  1241. .split(',')
  1242. .forEach(element => {
  1243. if (formData[element] instanceof Array) {
  1244. // 判断是否符合子表命名规则
  1245. if (element.indexOf('&') != -1) {
  1246. let tableChildNameList = element.split('&')
  1247. // 判断是否能拆分两个字符,子表标识和子表数据库名称
  1248. if (tableChildNameList.length == 2) {
  1249. i++
  1250. let childName = tableChildNameList[1] // 子表数据库名称
  1251. if (!formData.table_name_children) {
  1252. // 第一次拼接
  1253. formData.table_name_children = childName // 表名
  1254. } else {
  1255. // 后面的表明拼接用“,”隔开
  1256. formData.table_name_children = formData.table_name_children + ',' + childName // 表名
  1257. }
  1258. // 定义属性名和值
  1259. formData['childFiledNames' + i] = _.keys(formData[element][0]).join(',') // 子表字段名
  1260. formData['childList' + i] = JSON.stringify(formData[element]) // 子表数据
  1261. ischild = true
  1262. }
  1263. } else {
  1264. // 如果不是子表则是上传文件,则转字符串
  1265. formData[element] = JSON.stringify(formData[element])
  1266. }
  1267. }
  1268. // formData[element];
  1269. })
  1270. // 判断需不需要存子表
  1271. if (ischild) {
  1272. formData.filedNames = formData.filedNames + ',table_name_children'
  1273. }
  1274. console.log(formData)
  1275. // 子表数据
  1276. // 调用保存接口
  1277. this.todoManageOperationObject.formData = formData
  1278. this.todoManageOperationObject.url = url
  1279. // formData.jsonContent=JSON.stringify(this.jsonData).toString()
  1280. // 获取是否部门负责人
  1281. formData.filedNames = formData.filedNames + ',is_leaders'
  1282. // formData.is_leaders = this.$store.getters.userInfo.identity
  1283. formData.is_leaders = this.$store.getters.userInfo.isPossess
  1284. // 清除子表规则的属性
  1285. _.keys(formData).forEach(r => {
  1286. if (r.indexOf('child&') != -1) {
  1287. delete formData[r]
  1288. }
  1289. })
  1290. // 如果手机端子表得则需要修改json
  1291. // var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
  1292. var jsonPamats = JSON.parse(JSON.stringify(this.jsonDataSave))
  1293. if (!this.isSJ && this.isNew) {
  1294. jsonPamats = null
  1295. }
  1296. this.todoManageOperationObject.jsonData = jsonPamats
  1297. // 非我的待办节点打卡表单界面
  1298. if(addForm=='no'){
  1299. if(this.processData.businessTable == 'incident_ticket'){ // 森语-质量事故单-自动生成事故单号
  1300. if( this.processData.tableId==''|| !this.processData.tableId){
  1301. await this.getAction('/sys/user/getNextNo',{name:'accidentCode'}).then(res => {
  1302. formData.accident_number = res
  1303. })
  1304. }
  1305. }
  1306. if(this.processData.businessTable == 'expense_account'){//报销单-自动生成单号
  1307. if( this.processData.tableId==''|| !this.processData.tableId){
  1308. await this.getAction('/sys/user/getNextNo',{name:'BXDCode'}).then(res => {
  1309. formData.reimbursement_no=res
  1310. })
  1311. }
  1312. }
  1313. this.btndisabled = true
  1314. await postFormDataAction(url, formData, { jsonContent: jsonPamats })
  1315. .then(res => {
  1316. if (res.success) {
  1317. this.todoManageOperationObject.isSave = true
  1318. this.$message.success('保存成功!')
  1319. console.log('123')
  1320. this.$emit('afterSubmit', formData)
  1321. this.$emit('close')
  1322. // resolve(true);
  1323. } else {
  1324. this.$message.error(res.message)
  1325. // resolve(false);
  1326. }
  1327. })
  1328. .finally(() => {
  1329. this.btndisabled = false
  1330. // resolve(false);
  1331. })
  1332. }
  1333. })
  1334. .catch(err => {
  1335. console.log(err, '校验失败')
  1336. // resolve(false);
  1337. })
  1338. // })
  1339. },
  1340. // 我的待办点击通过保存专用
  1341. handleSubmit2 (e) {
  1342. // return new Promise((resolve)=>{
  1343. // 通过函数获取数据
  1344. this.$refs.KFB.getData()
  1345. .then(res => {
  1346. // 处理手机端子表数据
  1347. if (this.isSJ) {
  1348. this.itemData(res)
  1349. }
  1350. // 清除为空的表单数据
  1351. _.keys(res).forEach(r => {
  1352. if (!res[r]) {
  1353. delete res[r]
  1354. }
  1355. })
  1356. // 获取数据成功
  1357. let formData = JSON.parse(JSON.stringify(res))
  1358. console.log(formData)
  1359. formData.id = this.data.id
  1360. formData.procDefId = this.processData.id
  1361. formData.procDeTitle = this.processData.name
  1362. // formData.jsonContent=JSON.stringify(this.jsonData)
  1363. if (!formData.tableName) formData.tableName = this.processData.businessTable
  1364. formData.filedNames = _.keys(res).join(',')
  1365. formData.filedNames = getFiledNames(formData) // 获取主表字段,排除子表标识
  1366. var url = this.url.addApply
  1367. if (!this.isNew) {
  1368. url = this.url.editForm
  1369. }
  1370. // 是否存在子表
  1371. let ischild = false
  1372. // 循环表单字段属性判断是否属性中包含数组对象
  1373. let i = 0 // 子表数量
  1374. _.keys(res)
  1375. .join(',')
  1376. .split(',')
  1377. .forEach(element => {
  1378. if (formData[element] instanceof Array) {
  1379. // 判断是否符合子表命名规则
  1380. if (element.indexOf('&') != -1) {
  1381. let tableChildNameList = element.split('&')
  1382. // 判断是否能拆分两个字符,子表标识和子表数据库名称
  1383. if (tableChildNameList.length == 2) {
  1384. i++
  1385. let childName = tableChildNameList[1] // 子表数据库名称
  1386. if (!formData.table_name_children) {
  1387. // 第一次拼接
  1388. formData.table_name_children = childName // 表名
  1389. } else {
  1390. // 后面的表明拼接用“,”隔开
  1391. formData.table_name_children = formData.table_name_children + ',' + childName // 表名
  1392. }
  1393. // 定义属性名和值
  1394. formData['childFiledNames' + i] = _.keys(formData[element][0]).join(',') // 子表字段名
  1395. formData['childList' + i] = JSON.stringify(formData[element]) // 子表数据
  1396. ischild = true
  1397. }
  1398. } else {
  1399. // 如果不是子表则是上传文件,则转字符串
  1400. formData[element] = JSON.stringify(formData[element])
  1401. }
  1402. }
  1403. // formData[element];
  1404. })
  1405. // 判断需不需要存子表
  1406. if (ischild) {
  1407. formData.filedNames = formData.filedNames + ',table_name_children'
  1408. }
  1409. console.log(formData)
  1410. // 子表数据
  1411. // 调用保存接口
  1412. this.btndisabled = true
  1413. this.todoManageOperationObject.formData = formData
  1414. this.todoManageOperationObject.url = url
  1415. // 获取是否部门负责人
  1416. formData.filedNames = formData.filedNames + ',is_leaders'
  1417. // formData.is_leaders = this.$store.getters.userInfo.identity
  1418. formData.is_leaders = this.$store.getters.userInfo.isPossess
  1419. // 清除子表规则的属性
  1420. _.keys(formData).forEach(r => {
  1421. if (r.indexOf('child&') != -1) {
  1422. delete formData[r]
  1423. }
  1424. })
  1425. // 如果手机端子表得则需要修改json
  1426. // var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
  1427. var jsonPamats = JSON.parse(JSON.stringify(this.jsonDataSave))
  1428. if (!this.isSJ && this.isNew) {
  1429. jsonPamats = null
  1430. }
  1431. this.todoManageOperationObject.jsonData = jsonPamats
  1432. })
  1433. .catch(err => {
  1434. console.log(err, '校验失败')
  1435. // resolve(false);
  1436. })
  1437. // })
  1438. },
  1439. close () {
  1440. this.$emit('close')
  1441. },
  1442. getData () {
  1443. // 通过函数获取数据
  1444. this.$refs.KFB.getData()
  1445. .then(res => {
  1446. // 获取数据成功
  1447. alert(JSON.stringify(res))
  1448. })
  1449. .catch(err => {
  1450. console.log(err, '校验失败')
  1451. })
  1452. },
  1453. // 刷新待办列表
  1454. refreshToDo () {
  1455. this.close()
  1456. this.$emit('getDataList')
  1457. },
  1458. itemData (res) {
  1459. var childName = '' // 子表规则名称
  1460. var itemIndex = 0
  1461. this.jsonData.list.forEach((element, index) => {
  1462. if (element.label.indexOf('child&') != -1) {
  1463. childName = element.label // 获取规则名
  1464. itemIndex = itemIndex + 1
  1465. }
  1466. })
  1467. var itemList = [] // 封装子表数据
  1468. for (var i = 1; i <= itemIndex; i++) {
  1469. var itemObject = {} // 子表对象
  1470. this.itemModelNameList.forEach(name => {
  1471. // 获取子表得值和封装对象
  1472. itemObject[name] = res[name + '@' + i]
  1473. delete res[name + '@' + i]
  1474. })
  1475. itemList.push(itemObject)
  1476. }
  1477. res[childName] = itemList // 完成子表数据封装
  1478. console.log(res)
  1479. },
  1480. deleteRow (idIndex) {
  1481. // 删除
  1482. this.jsonData.list.splice(idIndex, 1)
  1483. // 删除掉得json之后 重新处理model 和value
  1484. let childIndex = 0
  1485. this.jsonData.list.forEach((element, index) => {
  1486. if (element.label.indexOf('child&') != -1) {
  1487. childIndex = childIndex + 1
  1488. // 只有当前删除的对象json的后面对象json才进行修改
  1489. if (index >= idIndex) {
  1490. // 修改删除按钮的index
  1491. element.columns[0].list[1].options.defaultValue =
  1492. '<a href="javascript:void(0);" \n onclick="deleteRow(' + childIndex + ')">删除</a>'
  1493. // 修改model
  1494. updateModel(element, childIndex)
  1495. // 需要调整的子表值
  1496. var updateModelObject = {}
  1497. // 修改value
  1498. this.$refs.KFB.getData().then(res => {
  1499. // 根据原始字段名拼接带规则的
  1500. this.itemModelNameList.forEach(modelName => {
  1501. updateModelObject[modelName + '@' + childIndex] = res[modelName + '@' + (childIndex + 1)]
  1502. })
  1503. this.$refs.KFB.setData(updateModelObject)
  1504. })
  1505. }
  1506. }
  1507. })
  1508. console.log(JSON.stringify(this.jsonData.list))
  1509. },
  1510. add () {
  1511. let childLable = '' // 子表json标题
  1512. let childValue = {} // 新增子表json
  1513. let isReturn = false
  1514. let childIndex = 0
  1515. var itemList = []
  1516. this.jsonData.list.forEach((element, index) => {
  1517. if (element.label.indexOf('child&') != -1) {
  1518. childValue = JSON.parse(JSON.stringify(element))
  1519. childLable = element.label
  1520. // 处理删除按钮
  1521. childIndex = childIndex + 1
  1522. // element.columns[0].list[1].options.dynamicFun = 'delete' + childIndex
  1523. console.log(element.columns[0].list[1].options)
  1524. element.columns[0].list[1].options.defaultValue =
  1525. '<a href="javascript:void(0);" \n onclick="deleteRow(' + childIndex + ')">删除</a>'
  1526. updateModel(childValue, childIndex)
  1527. }
  1528. if (!isReturn && childLable != '' && element.label != childLable) {
  1529. isReturn = true
  1530. // 处理删除按钮
  1531. childIndex = childIndex + 1
  1532. // childValue.columns[0].list[1].options.dynamicFun = 'delete' + childIndex
  1533. childValue.columns[0].list[1].options.defaultValue =
  1534. '<a href="javascript:void(0);" \n onclick="deleteRow(' + childIndex + ')">删除</a>'
  1535. updateModel(childValue, childIndex)
  1536. // this.jsonData.list.splice(index, 0, childValue)
  1537. itemList.push(childValue)
  1538. }
  1539. itemList.push(element)
  1540. })
  1541. this.jsonData.list = itemList
  1542. console.log(JSON.stringify(this.jsonData.list))
  1543. },
  1544. // 把整个子表json的model进行规则修改
  1545. async listUpdateModel () {
  1546. let modelIndex = 0 // 子表model自增
  1547. // 循环整个json的表单
  1548. this.jsonData.list.forEach((element, index) => {
  1549. // 找到为子表的json
  1550. if (element.label.indexOf('child&') != -1) {
  1551. this.isSJ = true
  1552. // 获取子表原始得model字段名
  1553. if (modelIndex == 0) {
  1554. var i = 1
  1555. var itemString = JSON.stringify(element)
  1556. var itemModelNameList = [] // 储存子表字段名
  1557. for (var i = 1; i !== -1;) {
  1558. // 动态字符位置
  1559. i = itemString.indexOf('"model"', i)
  1560. if (i !== -1) {
  1561. // 从指定字符的周后一个字符后开始找(")
  1562. var ihStart = itemString.indexOf('"', i + 7)
  1563. // 再从 (") 后面位置还是找下一个 (")
  1564. var ihEnd = itemString.indexOf('"', ihStart + 1)
  1565. // 获取引号之间的字符
  1566. var model = itemString.substring(ihStart + 1, ihEnd)
  1567. // 如果动态表示不为空则获取
  1568. if (model != '') {
  1569. if (model.indexOf('@') != -1) {
  1570. model = model.substring(0, model.length - 2)
  1571. }
  1572. itemModelNameList.push(model)
  1573. }
  1574. i = ihEnd + 1
  1575. }
  1576. }
  1577. this.itemModelNameList = itemModelNameList
  1578. }
  1579. modelIndex = modelIndex + 1
  1580. // 修改model
  1581. updateModel(element, modelIndex)
  1582. }
  1583. })
  1584. },
  1585. //计算时间差
  1586. timeDifference(start, end,state){
  1587. if(getProjctName() =='技能博物馆'){
  1588. var startDayArr = start.split(' '),
  1589. startDay = startDayArr[0]+' '+'16:00'
  1590. // 计算出请假第一天距离下班多久
  1591. var s1 = new Date(start.replace(/-/g, '/')),
  1592. s2 = new Date(startDay.replace(/-/g, '/')),
  1593. ms = Math.abs(s1.getTime() - s2.getTime()),
  1594. mins= (ms / 1000 / 60 / 60);
  1595. // ___________
  1596. var endDayArr = end.split(' '),
  1597. endDay = endDayArr[0]+' '+'9:00'
  1598. // 计算出请假最后一天距离上班多久
  1599. var s11 = new Date(end.replace(/-/g, '/')),
  1600. s22 = new Date(endDay.replace(/-/g, '/')),
  1601. ms2 = Math.abs(s11.getTime() - s22.getTime()),
  1602. mins2= (ms2 / 1000 / 60 / 60);
  1603. // ————————
  1604. var startDay = new Date(start),
  1605. endDay = new Date(end),
  1606. startDateTime=new Date(startDay.setDate(startDay.getDate()+1));
  1607. startDateTime =(moment(startDateTime).format('YYYY-MM-DD HH:mm')).split(' ')
  1608. var EndDateTime=new Date(endDay.setDate(endDay.getDate()-1));
  1609. EndDateTime =(moment(EndDateTime).format('YYYY-MM-DD HH:mm')).split(' ')
  1610. var myDate_1 = Date.parse(EndDateTime[0]),
  1611. myDate_2 = Date.parse(startDateTime[0])
  1612. //计算除去第一天和最后一天后相差多少天
  1613. var diffDate = Math.abs(myDate_1 - myDate_2), // 取相差毫秒数的绝对值
  1614. totalDays = Math.floor(diffDate / (1000 * 3600 * 24))+1 // 向下取整
  1615. if(startDateTime>EndDateTime){
  1616. totalDays = 0
  1617. }
  1618. var dayTime = (totalDays+(mins+mins2)/8).toFixed(1)
  1619. return dayTime
  1620. }else{
  1621. // if(start>end){
  1622. // this.$message.error('起始时间不可大于结束时间');
  1623. // }else{
  1624. let beginTime = (new Date(start).getTime()) / 1000;
  1625. let endTime = (new Date(end).getTime()) / 1000;
  1626. //计算天数
  1627. var timediff = endTime - beginTime;
  1628. var days = parseInt(timediff / 86400); //60*60*24
  1629. //计算小时数
  1630. var remain = timediff % 86400 ;
  1631. var hours = parseInt(remain / 3600);
  1632. //计算分钟数
  1633. var remain = remain % 3600;
  1634. var mins = parseInt(remain / 60);
  1635. var res = days + '天' + hours + '小时' + mins + '分';
  1636. if(state == 'min'){
  1637. return days*24*60+hours*60+mins
  1638. }else if(state == 'hour'){
  1639. return days*24+hours+mins/60
  1640. }else if(state == 'day'){
  1641. if(start.split(' ').length==1 && end.split(' ').length == 1){
  1642. return days+1+hours/24+mins/60/24
  1643. }else{
  1644. return days+hours/24+mins/60/24
  1645. }
  1646. }else if(state == 'day/hour/min'){
  1647. return days+'天'+hours+'小时'+mins+'分'
  1648. }else if(state == 'hour/min'){
  1649. return (days*24+hours)+'小时'+mins+'分'
  1650. }
  1651. }
  1652. }
  1653. }
  1654. // }
  1655. }
  1656. // 获取主表字段,排除子表标识
  1657. function getFiledNames (formData) {
  1658. let filedNames = ''
  1659. let list = formData.filedNames.split(',') // 获取表单属性名集合
  1660. list.forEach(element => {
  1661. if (element.indexOf('&') == -1) {
  1662. // 查询是否有这个字段
  1663. if (filedNames == '') {
  1664. // 第一次则直接等于
  1665. filedNames = element
  1666. } else {
  1667. // 后面用逗号隔开
  1668. filedNames = filedNames + ',' + element
  1669. }
  1670. }
  1671. })
  1672. return filedNames
  1673. }
  1674. // 根据开始时间 结束时间计算天数
  1675. function startEndFun (start, end) {
  1676. let startTime = new Date(start)
  1677. let endTime = new Date(end)
  1678. if (startTime >= endTime) {
  1679. return 0
  1680. }
  1681. // 1,分钟取整
  1682. startTime = carryTime(startTime)
  1683. endTime = carryTime(endTime)
  1684. // 2,计算总天数
  1685. var totalTime = 0 // 工时,天数
  1686. if (startTime.getDay() == 6 || startTime.getDay() == 0) {
  1687. totalTime = endTime.getDate() - startTime.getDate()
  1688. } else {
  1689. totalTime = Math.floor((endTime - startTime) / (3600 * 1000) / 24)
  1690. }
  1691. // 3,拿初始值赋值给一个临时变量
  1692. var tempStartTime = new Date()
  1693. tempStartTime.setTime(startTime.getTime())
  1694. // 4,计算出总天数
  1695. while (tempStartTime.getDate() < endTime.getDate()) {
  1696. if (tempStartTime.getDay() == 6 || tempStartTime.getDay() == 0) {
  1697. // 周六或者周日减去
  1698. totalTime--
  1699. }
  1700. tempStartTime.setDate(tempStartTime.getDate() + 1)
  1701. }
  1702. // 5,计算出总小时数
  1703. var temp = 0 // 工时,小时
  1704. do {
  1705. if (startTime.getDay() == 6 || startTime.getDay() == 0) {
  1706. // 周六周日
  1707. startTime.setDate(startTime.getDate() + 1)
  1708. //* ********周六周日直接跳过,初始化为早晨9点
  1709. startTime.setHours(9)
  1710. startTime.setMinutes(0)
  1711. continue
  1712. }
  1713. if (endTime.getDay() == 6 || endTime.getDay() == 0) {
  1714. // 周六周日
  1715. endTime.setDate(endTime.getDate() + 1)
  1716. //* ********周六周日直接跳过,初始化为早晨9点
  1717. endTime.setHours(9)
  1718. endTime.setMinutes(0)
  1719. continue
  1720. }
  1721. let tempMinutes = startTime.getHours() * 60 + startTime.getMinutes()
  1722. // 上午9点到12点半,算工时
  1723. if (tempMinutes >= 9 * 60 && tempMinutes < 12 * 60) {
  1724. temp += 0.05
  1725. }
  1726. // 上午14点到18点半,算工时
  1727. if (tempMinutes >= 13 * 60 && tempMinutes < 18 * 60) {
  1728. temp += 0.05
  1729. }
  1730. startTime.setTime(startTime.getTime() + 0.5 * 3600 * 1000) // 每次增加半个小时
  1731. } while (startTime.getHours() * 60 + startTime.getMinutes() != endTime.getHours() * 60 + endTime.getMinutes())
  1732. {
  1733. totalTime += Math.floor(temp / 0.8)
  1734. totalTime += temp % 0.8
  1735. totalTime = Math.round(totalTime * 100) / 100
  1736. }
  1737. var days = Math.floor(totalTime)
  1738. var hours = Math.round((totalTime - days) * 100) / 10
  1739. console.log(days + '天', hours + '小时')
  1740. return days * 8 + hours
  1741. // if (start && end) {
  1742. // let startTime = new Date(start) // 开始时间
  1743. // let endTime = new Date(end) // 结束时间
  1744. // let usedTime = endTime - startTime // 相差的毫秒数
  1745. // let days = (usedTime / 1000 / 60 / 60).toFixed(2) // 计算出天数
  1746. // return days
  1747. // } else {
  1748. // return null
  1749. // }
  1750. }
  1751. // 格式化时间
  1752. function formatDate (date, fmt) {
  1753. if (/(y+)/.test(fmt)) {
  1754. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
  1755. }
  1756. let o = {
  1757. 'M+': date.getMonth() + 1,
  1758. 'd+': date.getDate(),
  1759. 'h+': date.getHours(),
  1760. 'm+': date.getMinutes(),
  1761. 's+': date.getSeconds()
  1762. }
  1763. for (let k in o) {
  1764. if (new RegExp(`(${k})`).test(fmt)) {
  1765. let str = o[k] + ''
  1766. fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : padLeftZero(str))
  1767. }
  1768. }
  1769. return fmt
  1770. }
  1771. function padLeftZero (str) {
  1772. return ('00' + str).substr(str.length)
  1773. }
  1774. /*
  1775. * 0-15分不算工时
  1776. * 15-45算半个小时
  1777. * 45-60算一个小时
  1778. * */
  1779. function carryTime (date) {
  1780. if (date.getMinutes() > 0 && date.getMinutes() < 15) {
  1781. date.setMinutes(0)
  1782. }
  1783. if (date.getMinutes() >= 15 && date.getMinutes() < 30) {
  1784. date.setMinutes(30)
  1785. }
  1786. if (date.getMinutes() > 30 && date.getMinutes() < 45) {
  1787. date.setMinutes(30)
  1788. }
  1789. if (date.getMinutes() >= 45) {
  1790. date.setHours(date.getHours() + 1)
  1791. date.setMinutes(0)
  1792. }
  1793. return date
  1794. }
  1795. // function
  1796. /**
  1797. * 修改model绑定值
  1798. */
  1799. function updateModel (object, childIndex) {
  1800. let keyString = _.keys(object).join(',')
  1801. if (keyString.indexOf('model') != -1) {
  1802. // 如果没有修改过则直接修改
  1803. if (object['model'].indexOf('@') == -1) {
  1804. object['model'] = object['model'] + '@' + childIndex
  1805. } else {
  1806. // 修改过则截取修改前的再进行修改
  1807. var m = object['model'].substring(0, object['model'].length - 2)
  1808. object['model'] = m + '@' + childIndex
  1809. }
  1810. }
  1811. // 递归
  1812. _.keys(object)
  1813. .join(',')
  1814. .split(',')
  1815. .forEach(l => {
  1816. if (object[l] instanceof Array) {
  1817. object[l].forEach(element => {
  1818. updateModel(element, childIndex)
  1819. })
  1820. }
  1821. })
  1822. }
  1823. </script>
  1824. <style lang="less" scoped>
  1825. @media print {
  1826. @page {
  1827. /* 横向 */
  1828. size: landscape;
  1829. /* 去除浏览器默认页眉页脚 */
  1830. margin: 0;
  1831. }
  1832. * {
  1833. -webkit-print-color-adjust: exact !important; /* Chrome, Safari */
  1834. color-adjust: exact !important; /*Firefox*/
  1835. }
  1836. .noprint {
  1837. display: none;
  1838. }
  1839. /deep/ .ant-select-selection--multiple .ant-select-selection__rendered>ul>li, .ant-select-selection--multiple>ul>li{
  1840. font-size: 14px!important;
  1841. border: 0px solid black!important;
  1842. min-width: 150px!important;
  1843. height: 25!important;
  1844. }
  1845. /deep/ .ant-select-selection__choice__remove{
  1846. display: none;
  1847. }
  1848. // /deep/.ant-input{
  1849. // border: none !important;
  1850. // }
  1851. // /deep/ .ant-modal-header{
  1852. // display: none !important;
  1853. // }
  1854. // /deep/ .ant-modal-content{
  1855. // box-shadow:none !important
  1856. // }
  1857. /deep/ * {
  1858. color: #000000!important;
  1859. -webkit-tap-highlight-color: #000000!important;
  1860. }
  1861. /*update_end author:scott date:20191203 for:打印机打印的字体模糊问题 */
  1862. /deep/ .abcdefg .ant-card-body{
  1863. margin-left: 0%;
  1864. margin-right: 0%;
  1865. margin-bottom: 1%;
  1866. border:0px solid black;
  1867. min-width: 800px;
  1868. color:#000000!important;
  1869. }
  1870. /deep/ .explain{
  1871. text-align: left;
  1872. margin-left: 50px;
  1873. color:#000000!important;
  1874. }
  1875. /deep/ .explain .ant-input,.sign .ant-input{
  1876. font-weight:bolder;
  1877. text-align:center;
  1878. border-left-width:0px!important;
  1879. border-top-width:0px!important;
  1880. border-right-width:0px!important;
  1881. }
  1882. /deep/ .explain div{
  1883. margin-bottom: 10px;
  1884. }
  1885. /* you can make up upload button and sample style by using stylesheets */
  1886. /deep/ .ant-upload-select-picture-card i {
  1887. font-size: 32px;
  1888. color: #999;
  1889. }
  1890. /deep/ .ant-upload-select-picture-card .ant-upload-text {
  1891. margin-top: 8px;
  1892. color: #666;
  1893. }
  1894. }
  1895. /deep/ .anticon-question-circle-o {
  1896. display: none !important;
  1897. }
  1898. /deep/ textarea#presentation_condition {
  1899. height: 290px;
  1900. }
  1901. /deep/ textarea#expense_reason {
  1902. height: 290px;
  1903. }
  1904. /deep/ textarea#meeting_content {
  1905. height: 290px;
  1906. }
  1907. /deep/ .active .ant-select-selection {
  1908. border: 1px solid red;
  1909. }
  1910. /deep/ .ant-modal {
  1911. width: 57% !important;
  1912. }
  1913. </style>