demoForm2.vue 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496
  1. <template>
  2. <div class="form-main" id="form-main">
  3. <a-card :body-style="{ padding: '24px 32px' }" :bordered="false">
  4. <!-- <a-form @submit="handleSubmit" :form="form">
  5. <a-form-item
  6. label="标题"
  7. :labelCol="{lg: {span: 7}, sm: {span: 7}}"
  8. :wrapperCol="{lg: {span: 10}, sm: {span: 17} }">
  9. <a-input :disabled="disabled"
  10. v-decorator="[
  11. 'name',
  12. {rules: [{ required: true, message: '请输入标题' }]}
  13. ]"
  14. name="name"
  15. placeholder="给目标起个名字" />
  16. </a-form-item>
  17. <a-form-item v-if="!disabled"
  18. :wrapperCol="{ span: 24 }"
  19. style="text-align: center"
  20. >
  21. <a-button htmlType="submit" type="primary" :disabled="disabled||btndisabled" @click="handleSubmit">保存</a-button>
  22. <a-button style="margin-left: 8px" :disabled="disabled" @click="close">取消</a-button>
  23. </a-form-item>
  24. </a-form>-->
  25. <k-form-build
  26. :value="jsonData"
  27. @change="handleChange"
  28. :dynamicData="dynamicData"
  29. ref="KFB"
  30. @submit="handleSubmit"
  31. />
  32. <div style="text-align:center">
  33. <a-button
  34. htmlType="submit"
  35. type="primary"
  36. :disabled="disabled || btndisabled"
  37. @click="handleSubmit"
  38. class="noprint"
  39. >保存</a-button>
  40. <todoManageOperation
  41. v-if="processData.operationType && processData.operationType == '1'"
  42. :processData="processData"
  43. :todoManageOperationObject="todoManageOperationObject"
  44. :disabled="disabled"
  45. :btndisabled="btndisabled"
  46. @refreshToDo="refreshToDo"
  47. @handleSubmit2="handleSubmit2"
  48. ></todoManageOperation>
  49. <a-button style="margin-left: 8px;" :disabled="disabled || disabled2" @click="close" class="noprint">取消</a-button>
  50. <!-- <a-button type="primary" v-if="printDisable" @click="changedd" class="noprint" style="margin-left:10px">打印</a-button> -->
  51. </div>
  52. </a-card>
  53. <personnel-files-modal ref="personnelFilesModal" @close="closeP"></personnel-files-modal>
  54. <fixed-zy-modal ref="FixedZyModal" @close="closeP"></fixed-zy-modal>
  55. <car-sq-modal ref="CarSqModal" @close="closeP"></car-sq-modal>
  56. <material-sl-modal ref="MaterialSlModal" @close="closeP"></material-sl-modal>
  57. </div>
  58. </template>
  59. <script>
  60. import pick from 'lodash.pick'
  61. import todoManageOperation from '../operation/todoManageOperation'
  62. import PersonnelFilesModal from './personnelFilesModal'
  63. import CarSqModal from './carSqModal'
  64. import MaterialSlModal from './materialSlModal'
  65. import FixedZyModal from './fixedZyModal'
  66. import { postAction, postFormDataAction} from '@/api/manage'
  67. import {annualLeave} from '@api/oa/cd-personnel-files'
  68. import moment from 'moment'
  69. import {getProjctName}from '../../../../url.config'
  70. export default {
  71. name: 'DemoForm',
  72. props: {
  73. /* 全局禁用,可表示查看 */
  74. disabled: {
  75. type: Boolean,
  76. default: false,
  77. required: false
  78. },
  79. /* 流程数据 */
  80. processData: {
  81. type: Object,
  82. default: () => {
  83. return {}
  84. },
  85. required: false
  86. },
  87. /* 是否新增 */
  88. isNew: { type: Boolean, default: false, required: false }
  89. },
  90. components: {
  91. todoManageOperation,
  92. moment,
  93. PersonnelFilesModal,
  94. FixedZyModal,
  95. CarSqModal,
  96. MaterialSlModal,
  97. },
  98. data () {
  99. return {
  100. isSJ: false,
  101. todoManageOperationObject: {
  102. isSave: false,
  103. formData: {},
  104. jsonData: {}
  105. },
  106. leave:0,//剩余年假
  107. disabled2: false, // 用来取决于表单时不同流程节点填写不同表单信息使用
  108. jsonData: {}, // 前台任意改变的json
  109. jsonDataSave: {}, // 保存到数据库的json
  110. url: {
  111. getForm: '/actBusiness/getForm',
  112. addApply: '/actBusiness/add',
  113. editForm: '/actBusiness/editForm',
  114. leaveType: '/sys/dict/getDictItems'
  115. },
  116. description: '流程表单demo,按例开发表单。需在 activitiMixin.js 中加入写好的表单',
  117. // form
  118. form: this.$form.createForm(this),
  119. /* 表单回显数据 */
  120. data: {},
  121. btndisabled: false,
  122. ceshi_file: null,
  123. fArr:[],//保存含有help的单个表单信息
  124. cvarr:[],//保存表单所有的label和key(用来寻找改变字段对应的key)
  125. bv:[],//保存所有含有help的表单信息
  126. dynamicData: {
  127. jsonData: {},
  128. typeData: [], // 请假类型下拉数据
  129. reimbursementTypeList: [], // 报销类型下拉数据
  130. invoiceTypeList: [], // 发票类型下拉数据
  131. add: this.add,
  132. gv:this.funName,
  133. department:[],//技能博物管下拉框信息
  134. personListJn:[],//技能博物馆人员信息下拉框
  135. fundApproval:[],//技能博物馆项目信息
  136. conferenceRoom:[],//技能博物馆会议室信息
  137. },
  138. postInfo: {},//职位信息
  139. deptInfo: {},//部门信息
  140. itemModelNameList: [], // 子表字段名
  141. buttonArr:[],
  142. printDisable:false//打印按钮
  143. }
  144. },
  145. watch: {
  146. // 'dynamicData.jsonData'(){
  147. // console.log("发生改变了")
  148. // },
  149. dynamicData: {
  150. handler (newName, oldName) {
  151. console.log('obj.a changed')
  152. console.log(newName)
  153. console.log(oldName)
  154. newName.handle = this.funName1
  155. newName.fixed_zy = this.fixedZy
  156. newName.fixed_gh =this.fixedGh
  157. newName.fixed_db=this.fixedDb
  158. newName.fixed_bf=this.fixedBf
  159. newName.car_sq = this.carSq
  160. newName.material_sl = this.materialSl
  161. },
  162. immediate: true,
  163. deep: true
  164. }
  165. },
  166. created () {
  167. console.log("==============="+getProjctName());
  168. window.deleteRow = this.deleteRow
  169. // console.log('流程数据', this.processData)
  170. // 加载一些下拉选择数据等
  171. // this.getDataList()
  172. let businessTable = ''
  173. // 如果没有值则在另一个属性上有值
  174. if (!this.processData.businessTable) {
  175. this.processData.businessTable = this.processData.tableName
  176. }
  177. // debugger
  178. this.getAction('/tbTableInfo/query', {
  179. businessTable: this.processData.businessTable,
  180. taskNodeId: this.processData.key,
  181. tableId: this.processData.tableId,
  182. type: '1'
  183. }).then(res => {
  184. var jsonString = JSON.stringify(res.result.jsonContent)
  185. var index = 1
  186. var dynamicKeyValueList = []
  187. for (var index = 1; index !== -1;) {
  188. // 动态字符位置
  189. index = jsonString.indexOf('"dynamicKey"', index)
  190. if (index !== -1) {
  191. // 从指定字符的周后一个字符后开始找(")
  192. var ihStart = jsonString.indexOf('"', index + 12)
  193. // 再从 (") 后面位置还是找下一个 (")
  194. var ihEnd = jsonString.indexOf('"', ihStart + 1)
  195. // 获取引号之间的字符
  196. var dynamicKeyValue = jsonString.substring(ihStart + 1, ihEnd)
  197. // 如果动态表示不为空则获取
  198. if (dynamicKeyValue != '') {
  199. dynamicKeyValueList.push(dynamicKeyValue)
  200. }
  201. index = ihEnd + 1
  202. }
  203. }
  204. let that = this;
  205. if (dynamicKeyValueList.length > 0) {
  206. // 获取数据字典数据源
  207. postAction('/sys/dict/getDictItems/getDictList', dynamicKeyValueList).then(dictData => {
  208. if (dictData.success) {
  209. this.dynamicData = dictData.result.dicList
  210. if(getProjctName() =='技能博物馆'){
  211. //技能博物馆部门信息
  212. this.getAction('/sys/sysDepart/queryMyDeptList').then(res => {
  213. if (res.success) {
  214. var aa=[]
  215. res.result.map(item=>{
  216. aa.push({value:item.departName,label:item.departName})
  217. })
  218. this.dynamicData.department = aa
  219. } else {
  220. this.$message.error(res.message)
  221. }
  222. })
  223. //技能博物馆人员信息
  224. this.getAction('/sys/user/list', { pageSize: -1}).then(res => {
  225. if (res.success) {
  226. var aa = []
  227. res.result.records.map(item =>{
  228. aa.push(
  229. {value:item.realname,
  230. label:item.realname,
  231. workNo:item.workNo,
  232. post:item.post,
  233. nInductionTime:item.nInductionTimenInductionTime,
  234. phone:item.phone,
  235. telephone:item.telephone,
  236. departIds_dictText:item.departIds_dictText,
  237. departIds:item.departIds
  238. })
  239. })
  240. this.dynamicData.personListJn = aa
  241. //技能博物馆 --- 全馆值班 此时无法触碰到handleChange方法 手动触发
  242. if(this.processData.businessTable == 'bwg_house_duty'){
  243. this.handleChange()
  244. }
  245. } else {
  246. this.$message.error(res.message)
  247. }
  248. })
  249. //技能博物馆项目信息
  250. this.getAction('/oa/activiti/getSelectionList',{tableName:'bwg_project_start'}).then(res => {
  251. if (res.success) {
  252. var aa=[]
  253. res.result.map(item=>{
  254. aa.push(
  255. {value:item.project_name,
  256. label:item.project_name,
  257. startDate:item.start_date,
  258. endDate:item.end_date,
  259. projectReasons:item.project_reasons,
  260. budgetInformation:item.budget_information
  261. })
  262. })
  263. this.dynamicData.fundApproval = aa
  264. } else {
  265. this.$message.error(res.message)
  266. }
  267. })
  268. //技能博物馆会议室信息
  269. this.getAction('/oa/meetingRoom/all').then(res => {
  270. if (res.success) {
  271. var aa=[]
  272. res.result.map(item=>{
  273. aa.push({value:item.name,label:item.name})
  274. })
  275. this.dynamicData.conferenceRoom = aa
  276. } else {
  277. this.$message.error(res.message)
  278. }
  279. })
  280. }
  281. // 获取用户下拉数据
  282. this.getAction('/sys/user/list2', { pageSize: 20000 }).then(userData => {
  283. if (res.success) {
  284. if(userData.data != null && userData.data.supplierList != null){
  285. // userData.data.supplierList.forEach(user => {
  286. // console.log("userDatacode",user.code);
  287. // console.log("userDataname",user.name);
  288. // })
  289. this.dynamicData.supplierList = userData.data.supplierList
  290. }
  291. userData.result.records.forEach(user => {
  292. user.label = user.realname
  293. user.value = user.username
  294. that.postInfo[user.username] = user.post
  295. that.deptInfo[user.username] = user.deptName
  296. })
  297. // 存到动态数据源中
  298. this.dynamicData.userList = userData.result.records
  299. this.dynamicData.add = this.add // 新增按钮
  300. // 获取json
  301. this.jsonData = res.result.jsonContent
  302. // this.jsonData.list[2].columns[0].list[0].help = "date_1663752082983,date_1663753163575,min"
  303. this.cvarr = []
  304. this.cvarr = []
  305. this.fArr =[]
  306. //遍历help
  307. this.forHelp(this.jsonData)
  308. this.jsonDataSave = JSON.parse(JSON.stringify(res.result.jsonContent))
  309. // 获取申请人信息
  310. this.getApplicant()
  311. // 如果是手机端子表初始化子表model
  312. this.listUpdateModel()
  313. if (!this.isNew) {
  314. this.init()
  315. }
  316. } else {
  317. this.$message.error(userData.message)
  318. }
  319. })
  320. } else {
  321. this.$message.error(dictData.message)
  322. }
  323. })
  324. } else {
  325. // 获取json
  326. this.jsonData = res.result.jsonContent
  327. // this.jsonData.list[0].trs[5].tds[2].list[0].help = 'input_1662521241170,input_1662521240862,-'
  328. // this.jsonData.list[0].trs[3].tds[2].list[0].help = 'today'
  329. this.cvarr = []
  330. this.fArr =[]
  331. //遍历help(计算)
  332. this.forHelp(this.jsonData)
  333. // 获取申请人信息
  334. this.getApplicant()
  335. // 如果是手机端子表初始化子表model
  336. this.listUpdateModel()
  337. // window.jsonData=this.jsonData;
  338. if (!this.isNew) {
  339. this.init()
  340. }
  341. }
  342. // 后台检测到流程节点有关联表单且前台处于我的待办界面打开表单详情
  343. if (res.result.isSave && this.processData.isSuspended != undefined) {
  344. this.disabled = false
  345. this.btndisabled = false
  346. }
  347. })
  348. },
  349. methods: {
  350. fixedZy(){
  351. this.$refs.FixedZyModal.fixedZyModVis = true
  352. this.$refs.FixedZyModal.personLists('正常')
  353. this.$refs.FixedZyModal.sat = '转移'
  354. },
  355. fixedGh(){
  356. this.$refs.FixedZyModal.fixedZyModVis = true
  357. this.$refs.FixedZyModal.personLists('正常')
  358. this.$refs.FixedZyModal.sat = '归还'
  359. },
  360. fixedDb(){
  361. this.$refs.FixedZyModal.fixedZyModVis = true
  362. this.$refs.FixedZyModal.personLists('正常')
  363. this.$refs.FixedZyModal.sat = '调拨'
  364. },
  365. fixedBf(){
  366. this.$refs.FixedZyModal.fixedZyModVis = true
  367. this.$refs.FixedZyModal.personLists('正常')
  368. this.$refs.FixedZyModal.sat = '报废'
  369. },
  370. carSq(){
  371. this.$refs.CarSqModal.carSqModVis = true
  372. this.$refs.CarSqModal.personLists()
  373. },
  374. materialSl(){
  375. this.$refs.MaterialSlModal.materialSlModVis = true
  376. this.$refs.MaterialSlModal.personLists()
  377. },
  378. //获取部门信息
  379. getDepartment(){
  380. this.$refs.DepartmentModal.departmentModVis = true
  381. this.$refs.DepartmentModal.personLists()
  382. },
  383. closeP(value){
  384. var that = this
  385. this.cvarr.map(item=>{
  386. for(let key in value){
  387. if(item.model == key){
  388. setTimeout(function(){
  389. that.$refs.KFB.setData({[key]:value[key]})
  390. },0)
  391. }
  392. }
  393. })
  394. },
  395. funName1(){
  396. this.$refs.personnelFilesModal.declareElementsModVis = true
  397. this.$refs.personnelFilesModal.personLists()
  398. },
  399. // 根据字典名字获取数据源
  400. getDataListByName (name) {
  401. this.getAction(this.url.leaveType + '/' + name).then(res => {
  402. if (res.success) {
  403. this.dynamicData[name] = res.result
  404. console.log(111)
  405. } else {
  406. this.$message.error(res.message)
  407. }
  408. })
  409. },
  410. // 获取获取下拉数据等
  411. getDataList () {
  412. // 获取请假类型下拉数据
  413. this.getAction(this.url.leaveType + '/leave_type').then(res => {
  414. if (res.success) {
  415. this.dynamicData.typeData = res.result
  416. } else {
  417. this.$message.error(res.message)
  418. }
  419. })
  420. // 获取报销类型下拉数据
  421. this.getAction(this.url.leaveType + '/reimbursement_type').then(res => {
  422. if (res.success) {
  423. this.dynamicData.reimbursementTypeList = res.result
  424. } else {
  425. this.$message.error(res.message)
  426. }
  427. })
  428. // 获取发票类型下拉数据
  429. this.getAction(this.url.leaveType + '/invoice_type').then(res => {
  430. if (res.success) {
  431. this.dynamicData.invoiceTypeList = res.result
  432. } else {
  433. this.$message.error(res.message)
  434. }
  435. })
  436. },
  437. /* 回显数据 */
  438. init () {
  439. this.btndisabled = true
  440. var r = this.processData
  441. this.getAction(this.url.getForm, {
  442. tableId: r.tableId,
  443. tableName: r.tableName
  444. }).then(res => {
  445. // 第一次调接口根据子表数据渲染子表前台效果
  446. // 只有手机端才执行
  447. if (this.isSJ) {
  448. _.keys(res.result).forEach((e, i) => {
  449. if (e.indexOf('child&') != -1) {
  450. if (i > 0) {
  451. this.add()
  452. }
  453. }
  454. })
  455. }
  456. this.getAction(this.url.getForm, {
  457. tableId: r.tableId,
  458. tableName: r.tableName
  459. }).then(res => {
  460. if (res.success) {
  461. let formData = res.result
  462. formData.tableName = r.tableName
  463. // console.log("taboe",formData);
  464. this.data = formData
  465. // 如果表单是手机端的子表则
  466. if (this.isSJ) {
  467. var formModelList = _.keys(this.data)
  468. .join(',')
  469. .split(',')
  470. var itemList = []
  471. formModelList.forEach(element => {
  472. if (element.indexOf('child&') != -1) {
  473. itemList = JSON.parse(JSON.stringify(this.data[element]))
  474. delete this.data[element]
  475. }
  476. })
  477. // 子表字段名
  478. // 子表数据model和值组装
  479. itemList.forEach((item, index) => {
  480. this.itemModelNameList.forEach(itemModelName => {
  481. this.data[itemModelName + '@' + (index + 1)] = item[itemModelName]
  482. })
  483. })
  484. }
  485. // 赋值
  486. this.$refs.KFB.setData(this.data)
  487. this.btndisabled = false
  488. } else {
  489. this.$message.error(res.message)
  490. }
  491. })
  492. })
  493. },
  494. //遍历help
  495. forHelp(obj){
  496. for(var a in obj){
  497. if (typeof(obj[a]) == "object"){
  498. if(obj[a].help !=='' && obj[a].help){
  499. //保存每一项的label和key
  500. this.cvarr.push({model:obj[a].model,key:obj[a].key,type:obj[a].type})
  501. obj[a].help = obj[a].help.split(',')
  502. //保存含有help的item中的label和help里的信息
  503. this.fArr=[
  504. {
  505. label:obj[a].model,
  506. value:'',
  507. },
  508. {
  509. label: obj[a].help[0],
  510. value:'',
  511. },
  512. {
  513. label: obj[a].help[1],
  514. value:'',
  515. },
  516. {
  517. label: obj[a].help[2],
  518. value:'',
  519. },
  520. ]
  521. //保存多各含有help的数据
  522. this.bv.push({bn:this.fArr})
  523. //默认当天时间
  524. this.defualtData(this.fArr)
  525. }else if(obj[a].help ==''){
  526. this.cvarr.push({model:obj[a].model,key:obj[a].key,type:obj[a].type})
  527. }else if(obj[a].type == 'button'){
  528. this.buttonArr.push(obj[a])
  529. this.buttonShow(obj[a])
  530. }
  531. this.forHelp(obj[a])
  532. }
  533. }
  534. },
  535. buttonShow(obj){
  536. if(obj.label == '打印'){
  537. this.printDisable = true
  538. }
  539. },
  540. defualtData(item){
  541. if(item[1].label =='today'){
  542. item[0].value =moment(new Date().toLocaleDateString()).format('YYYY-MM-DD HH:mm')
  543. var that = this
  544. setTimeout(function(){
  545. that.$refs.KFB.setData({[item[0].label]:item[0].value})
  546. },0)
  547. }else if(item[1].label =='user'){
  548. this.$store.getters.userInfo
  549. var that = this
  550. setTimeout(function(){
  551. that.$refs.KFB.setData({[item[0].label]:that.$store.getters.userInfo.username})
  552. if(that.processData.businessTable == 'regular_employee_apply'){//员工转正申请
  553. that.$refs.KFB.setData({apply_department:that.deptInfo[that.$store.getters.userInfo.username]})
  554. // that.$refs.KFB.setData({job_title:that.postInfo[that.$store.getters.userInfo.username]})
  555. }
  556. if(that.processData.businessTable == 'seal_apply'){//用印申请单
  557. that.$refs.KFB.setData({apply_department:that.deptInfo[that.$store.getters.userInfo.username]})
  558. }
  559. if(that.processData.businessTable == 'separation_application'){//离职申请
  560. that.$refs.KFB.setData({job_title:that.postInfo[that.$store.getters.userInfo.username]})
  561. }
  562. if(that.processData.businessTable == 'bwg_house_duty'){ // 技能博物馆--全馆值班 --默认当前登陆人
  563. that.$refs.KFB.setData({referrer:that.$store.getters.nickname})
  564. that.dynamicData.personListJn.map(item =>{
  565. if(item.label == that.$store.getters.nickname){
  566. that.$refs.KFB.setData({department_id:item.departIds})
  567. that.$refs.KFB.setData({department_name:item.departIds_dictText})
  568. that.$refs.KFB.setData({mobile_telephone:item.phone})
  569. that.$refs.KFB.setData({telephone:item.telephone})
  570. }
  571. })
  572. }
  573. },0)
  574. annualLeave({username:that.$store.getters.userInfo.username}).then(res => {
  575. if (res.success) {
  576. this.leave = res.result.nannualNowNum
  577. }else{
  578. this.$message.error(res.message);
  579. }
  580. })
  581. }
  582. },
  583. // 获取申请人信息
  584. getApplicant () {
  585. console.log('aa', this.$refs.KFB.form.getFieldValue('applicant'))
  586. // if (this.$refs.KFB.form.getFieldValue('applicant')) {
  587. // alert(1)
  588. // this.$refs.KFB.setData({
  589. // applicant: this.$store.getters.userInfo.username
  590. // })
  591. // }
  592. },
  593. changedd(){
  594. window.print()
  595. },
  596. //主子表计算
  597. tableCalculation(value){
  598. var number1 = 0,
  599. number2 = 0
  600. //寻找help信息中对应的modol值
  601. this.bv.map(item=>{
  602. this.cvarr.map(vv=>{
  603. if(vv.key == item.bn[1].label){
  604. number1 = vv.model
  605. }else if(vv.key == item.bn[2].label){
  606. number2 = vv.model
  607. }
  608. })
  609. //表中每一行分别计算
  610. var sum = 0
  611. value.map(b=>{
  612. b[item.bn[0].label] = b[number1]*b[number2]
  613. sum += b[item.bn[0].label] //计算出表格内的总价总和
  614. if(this.$store.getters.nickname=='崔崇杰'){
  615. b['procurement_type']='1'
  616. }else{
  617. b['procurement_type']='2'
  618. }
  619. })
  620. this.$refs.KFB.setData({sum:sum})
  621. })
  622. },
  623. specialTerms(value,key){
  624. var that = this
  625. //剩余年假
  626. if(key == 'employe_name'){
  627. setTimeout(function(){
  628. annualLeave({username:value}).then(res => {
  629. if (res.success) {
  630. //选择姓名获取页面的请假类型和时间间隔
  631. that.leave = res.result.nannualNowNum
  632. var category = that.$refs.KFB.form.getFieldValue('leave_category')
  633. var time1 = that.$refs.KFB.form.getFieldValue('start_date')
  634. var time2 = that.$refs.KFB.form.getFieldValue('end_date')
  635. var timeC=that.timeDifference(time1,time2,'min') //获取时间差
  636. //事假,超过180分钟,年假大于0.5
  637. if(category == 1 &&timeC>=180&&that.leave>=0.5){
  638. that.$refs.KFB.setData({unit:'2'})
  639. that.$refs.KFB.setData({leave_category:'2'})
  640. }else if(category == 2 && that.leave<0.5){ //类型为年假,剩余年假小于0.5
  641. that.$refs.KFB.setData({unit:'1'})
  642. that.$refs.KFB.setData({leave_category:''})
  643. that.$message.error('剩余年假不足!');
  644. }
  645. }else{
  646. that.$message.error(res.message);
  647. }
  648. })
  649. },0)
  650. }
  651. //请假类型与单位
  652. //事假
  653. if(key == 'leave_category' && value == '1'){
  654. setTimeout(function(){
  655. var time1 = that.$refs.KFB.form.getFieldValue('start_date')
  656. var time2 = that.$refs.KFB.form.getFieldValue('end_date')
  657. var timeC=that.timeDifference(time1,time2,'min') //获取时间差
  658. if(timeC>=180 && that.leave>=0.5){ //事假,时间差大于180,剩余年假大于0.5
  659. that.$refs.KFB.setData({unit:'2'})
  660. that.$refs.KFB.setData({leave_category:'2'})
  661. }else{
  662. that.$refs.KFB.setData({unit:'1'})
  663. }
  664. },0)
  665. }else if(key == 'leave_category' && value == '3'){ //病假
  666. setTimeout(function(){
  667. that.$refs.KFB.setData({unit:'1'})
  668. },0)
  669. }else if(key == 'leave_category' && value == '2'){//年假
  670. setTimeout(function(){
  671. if(that.leave >=0.5){ //剩余年假大于0.5
  672. that.$refs.KFB.setData({unit:'2'})
  673. }else{ //剩余年假小于0.5
  674. that.$refs.KFB.setData({unit:'1'})
  675. that.$refs.KFB.setData({leave_category:''})
  676. that.$message.error('剩余年假不足!');
  677. }
  678. },0)
  679. }else if(key == 'leave_category'){
  680. setTimeout(function(){
  681. that.$refs.KFB.setData({unit:'2'})
  682. },0)
  683. }
  684. //时间间隔和类型
  685. if(key =='start_date' || key =='end_date'){
  686. setTimeout(function(){
  687. var time2 = that.$refs.KFB.form.getFieldValue('end_date')
  688. var time1 = that.$refs.KFB.form.getFieldValue('start_date')
  689. var timeC=that.timeDifference(time1,time2,'min')
  690. var lx=that.$refs.KFB.form.getFieldValue('leave_category')
  691. if(timeC>=180&&lx=='1'&&that.leave>=0.5){ //事假,时间差大于180,剩余年假大于0.5
  692. that.$refs.KFB.setData({unit:'2'})
  693. that.$refs.KFB.setData({leave_category:'2'})
  694. }
  695. },0)
  696. }
  697. },
  698. // 表单字段数值发生改变事件
  699. handleChange (value, key) {
  700. if(key == 'proposer' && this.processData.businessTable == 'regular_employee_apply'){//员工转正申请:申请人部门
  701. this.$refs.KFB.setData({apply_department:this.deptInfo[value]})
  702. }
  703. if(key == 'regular_employee' && this.processData.businessTable == 'regular_employee_apply'){//员工转正申请:转正人员岗位
  704. this.$refs.KFB.setData({job_title:this.postInfo[value]})
  705. }
  706. if(key == 'proposer' && this.processData.businessTable == 'seal_apply'){//用印申请单
  707. this.$refs.KFB.setData({apply_department:this.deptInfo[value]})
  708. }
  709. if(key == 'employee_name' && this.processData.businessTable == 'separation_application'){//离职申请
  710. this.$refs.KFB.setData({job_title:this.postInfo[value]})
  711. }
  712. //技能博物馆-----退休录入
  713. if(key == 'name' && this.processData.businessTable == 'bwg_retire_input'){//技能博物馆 ---- 退休录入
  714. this.dynamicData.personListJn.map(item =>{
  715. if(item.label == value){
  716. this.$refs.KFB.setData({employee_number:item.workNo})
  717. this.$refs.KFB.setData({post:item.post})
  718. this.$refs.KFB.setData({rz_date:item.nInductionTim})
  719. }
  720. })
  721. // this.$refs.KFB.setData({employee_number:this.postInfo[value]})
  722. }
  723. //技能博物馆-----离职录入
  724. if(key == 'name' && this.processData.businessTable == 'bwg_quit_input'){//技能博物馆 ---- 退休录入
  725. this.dynamicData.personListJn.map(item =>{
  726. if(item.label == value){
  727. this.$refs.KFB.setData({employee_number:item.workNo})
  728. this.$refs.KFB.setData({post:item.post})
  729. this.$refs.KFB.setData({rz_date:item.nInductionTim})
  730. }
  731. })
  732. }
  733. //技能博物馆 ----- 费用报销
  734. if(key == 'expense_person' && this.processData.businessTable == 'bwg_expense_apply'){
  735. this.dynamicData.personListJn.map(item =>{
  736. if(item.label == value){
  737. this.$refs.KFB.setData({expense_department:item.departIds_dictText})
  738. }
  739. })
  740. }
  741. //技能博物馆 --- 会议纪要
  742. if(this.processData.businessTable == 'bwg_meeting_summary'){
  743. this.dynamicData.personListJn.map(item =>{
  744. if(item.label == this.$store.getters.nickname){
  745. this.$refs.KFB.setData({record_person:item.value})
  746. this.$refs.KFB.setData({record_department:item.departIds_dictText})
  747. }
  748. })
  749. }
  750. //技能博物馆 ----部门专项预算
  751. if(key == 'department' && this.processData.businessTable == 'bwg_department_budget'){
  752. //预算年份未选择
  753. var year = this.$refs.KFB.form.getFieldValue('budget_year')
  754. if(year == '' || !year){
  755. var that =this
  756. that.$message.error('请先选择报销年份');
  757. setTimeout(function(){
  758. that.$refs.KFB.setData({department:' '})
  759. },0)
  760. }else{ //已选择年份 获取预算金额
  761. this.getAction('/oa/budget/getSelectionList',{year:year,budgetType:'部门预算',dept:value}).then(res => {
  762. if (res.success) {
  763. var money = res.result[0].amount
  764. this.$refs.KFB.setData({budget_sum:money})
  765. } else {
  766. this.$message.error(res.message)
  767. }
  768. })
  769. }
  770. }
  771. //技能博物馆 ----资金审批
  772. if(key == 'project_name' && this.processData.businessTable == 'bwg_capital_approval'){
  773. this.dynamicData.fundApproval.map(item =>{
  774. if(item.label == value){
  775. this.$refs.KFB.setData({start_data:item.startDate})
  776. this.$refs.KFB.setData({end_date:item.endDate})
  777. this.$refs.KFB.setData({project_reasons:item.projectReasons})
  778. this.$refs.KFB.setData({budget_information:item.budgetInformation})
  779. }
  780. })
  781. }
  782. //改变的表单是主子表类型时
  783. if((value instanceof Array) && (key.indexOf('child&')!==-1)){
  784. this.tableCalculation(value)
  785. }
  786. //特别字段
  787. this.specialTerms(value,key)
  788. //代码赘余,日后维护
  789. //保存发生改变字段名对应的key
  790. var cc ='',
  791. type = ''
  792. this.cvarr.map(k =>{
  793. if(k.model ==key){
  794. cc=k.key
  795. type = k.type
  796. }})
  797. //根据数值改变计算
  798. var that =this
  799. setTimeout(function(){
  800. that.bv.map(event =>{
  801. if(event.bn[1].label == cc || event.bn[2].label == cc){
  802. that.cvarr.map(k=>{
  803. if(k.key == event.bn[1].label){
  804. event.bn[1].value = that.$refs.KFB.form.getFieldValue(k.model)
  805. }else if(k.key == event.bn[2].label){
  806. event.bn[2].value = that.$refs.KFB.form.getFieldValue(k.model)
  807. }
  808. })
  809. if(type == 'date'){
  810. if(event.bn[1].value!=='' && event.bn[2].value!==''){
  811. var state = ''
  812. state = event.bn[3].label
  813. event.bn[0].value = that.timeDifference(event.bn[1].value,event.bn[2].value,state)
  814. }
  815. }else{
  816. if(event.bn[3].label =="+"){
  817. event.bn[0].value = Number(event.bn[1].value)+Number(event.bn[2].value)
  818. }else if(event.bn[3].label =="-"){
  819. event.bn[0].value = Number(event.bn[1].value)-Number(event.bn[2].value)
  820. }else if(event.bn[3].label =="*"){
  821. event.bn[0].value = Number(event.bn[1].value)*Number(event.bn[2].value)
  822. }
  823. }
  824. that.$refs.KFB.setData({[event.bn[0].label]:event.bn[0].value})
  825. }
  826. })
  827. },0)
  828. // // 数据变化时触发
  829. // // 如果开始时间发生变化
  830. // if (key == 'start_time') {
  831. // // 判断结束时间是否存在
  832. // if (this.$refs.KFB.form.getFieldValue('end_time')) {
  833. // // 获取时间差
  834. // let duration = startEndFun(value, this.$refs.KFB.form.getFieldValue('end_time'))
  835. // if (duration) {
  836. // // 使用k-form-design组件的form属性修改表单数据
  837. // this.$refs.KFB.setData({
  838. // duration: duration
  839. // })
  840. // }
  841. // }
  842. // }
  843. // // 如果结束时间发生变化
  844. // if (key == 'end_time') {
  845. // // 判断结束时间是否存在
  846. // if (this.$refs.KFB.form.getFieldValue('start_time')) {
  847. // // 获取时间差
  848. // let duration = startEndFun(this.$refs.KFB.form.getFieldValue('start_time'), value)
  849. // if (duration) {
  850. // // 使用k-form-design组件的form属性修改表单数据
  851. // this.$refs.KFB.setData({
  852. // duration: duration
  853. // })
  854. // }
  855. // }
  856. // }
  857. },
  858. // handler
  859. handleSubmit (e) {
  860. // return new Promise((resolve)=>{
  861. // 通过函数获取数据
  862. this.$refs.KFB.getData()
  863. .then(res => {
  864. let formData1 = JSON.parse(JSON.stringify(res))
  865. console.log("orl",formData1)
  866. // 处理手机端子表数据
  867. if (this.isSJ) {
  868. this.itemData(res)
  869. }
  870. // 清除为空的表单数据
  871. _.keys(res).forEach(r => {
  872. if (!res[r]) {
  873. delete res[r]
  874. }
  875. })
  876. // 获取数据成功
  877. let formData = JSON.parse(JSON.stringify(res))
  878. console.log(formData)
  879. formData.id = this.data.id
  880. formData.procDefId = this.processData.id
  881. formData.procDeTitle = this.processData.name
  882. if (!formData.tableName) formData.tableName = this.processData.businessTable
  883. formData.filedNames = _.keys(res).join(',')
  884. formData.filedNames = getFiledNames(formData) // 获取主表字段,排除子表标识
  885. var url = this.url.addApply
  886. if (!this.isNew) {
  887. url = this.url.editForm
  888. }
  889. // 是否存在子表
  890. let ischild = false
  891. // 循环表单字段属性判断是否属性中包含数组对象
  892. let i = 0 // 子表数量
  893. _.keys(res)
  894. .join(',')
  895. .split(',')
  896. .forEach(element => {
  897. if (formData[element] instanceof Array) {
  898. // 判断是否符合子表命名规则
  899. if (element.indexOf('&') != -1) {
  900. let tableChildNameList = element.split('&')
  901. // 判断是否能拆分两个字符,子表标识和子表数据库名称
  902. if (tableChildNameList.length == 2) {
  903. i++
  904. let childName = tableChildNameList[1] // 子表数据库名称
  905. if (!formData.table_name_children) {
  906. // 第一次拼接
  907. formData.table_name_children = childName // 表名
  908. } else {
  909. // 后面的表明拼接用“,”隔开
  910. formData.table_name_children = formData.table_name_children + ',' + childName // 表名
  911. }
  912. // 定义属性名和值
  913. formData['childFiledNames' + i] = _.keys(formData[element][0]).join(',') // 子表字段名
  914. formData['childList' + i] = JSON.stringify(formData[element]) // 子表数据
  915. ischild = true
  916. }
  917. } else {
  918. // 如果不是子表则是上传文件,则转字符串
  919. formData[element] = JSON.stringify(formData[element])
  920. }
  921. }
  922. // formData[element];
  923. })
  924. // 判断需不需要存子表
  925. if (ischild) {
  926. formData.filedNames = formData.filedNames + ',table_name_children'
  927. }
  928. console.log(formData)
  929. // 子表数据
  930. // 调用保存接口
  931. this.btndisabled = true
  932. this.todoManageOperationObject.formData = formData
  933. this.todoManageOperationObject.url = url
  934. // formData.jsonContent=JSON.stringify(this.jsonData).toString()
  935. // 获取是否部门负责人
  936. formData.filedNames = formData.filedNames + ',is_leaders'
  937. // formData.is_leaders = this.$store.getters.userInfo.identity
  938. formData.is_leaders = this.$store.getters.userInfo.isPossess
  939. // 清除子表规则的属性
  940. _.keys(formData).forEach(r => {
  941. if (r.indexOf('child&') != -1) {
  942. delete formData[r]
  943. }
  944. })
  945. // 如果手机端子表得则需要修改json
  946. // var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
  947. var jsonPamats = JSON.parse(JSON.stringify(this.jsonDataSave))
  948. if (!this.isSJ && this.isNew) {
  949. jsonPamats = null
  950. }
  951. this.todoManageOperationObject.jsonData = jsonPamats
  952. // 非我的待办节点打卡表单界面
  953. postFormDataAction(url, formData, { jsonContent: jsonPamats })
  954. .then(res => {
  955. if (res.success) {
  956. this.todoManageOperationObject.isSave = true
  957. this.$message.success('保存成功!')
  958. console.log('123')
  959. this.$emit('afterSubmit', formData)
  960. this.$emit('close')
  961. // resolve(true);
  962. } else {
  963. this.$message.error(res.message)
  964. // resolve(false);
  965. }
  966. })
  967. .finally(() => {
  968. this.btndisabled = false
  969. // resolve(false);
  970. })
  971. })
  972. .catch(err => {
  973. console.log(err, '校验失败')
  974. // resolve(false);
  975. })
  976. // })
  977. },
  978. // 我的待办点击通过保存专用
  979. handleSubmit2 (e) {
  980. // return new Promise((resolve)=>{
  981. // 通过函数获取数据
  982. this.$refs.KFB.getData()
  983. .then(res => {
  984. // 处理手机端子表数据
  985. if (this.isSJ) {
  986. this.itemData(res)
  987. }
  988. // 清除为空的表单数据
  989. _.keys(res).forEach(r => {
  990. if (!res[r]) {
  991. delete res[r]
  992. }
  993. })
  994. // 获取数据成功
  995. let formData = JSON.parse(JSON.stringify(res))
  996. console.log(formData)
  997. formData.id = this.data.id
  998. formData.procDefId = this.processData.id
  999. formData.procDeTitle = this.processData.name
  1000. // formData.jsonContent=JSON.stringify(this.jsonData)
  1001. if (!formData.tableName) formData.tableName = this.processData.businessTable
  1002. formData.filedNames = _.keys(res).join(',')
  1003. formData.filedNames = getFiledNames(formData) // 获取主表字段,排除子表标识
  1004. var url = this.url.addApply
  1005. if (!this.isNew) {
  1006. url = this.url.editForm
  1007. }
  1008. // 是否存在子表
  1009. let ischild = false
  1010. // 循环表单字段属性判断是否属性中包含数组对象
  1011. let i = 0 // 子表数量
  1012. _.keys(res)
  1013. .join(',')
  1014. .split(',')
  1015. .forEach(element => {
  1016. if (formData[element] instanceof Array) {
  1017. // 判断是否符合子表命名规则
  1018. if (element.indexOf('&') != -1) {
  1019. let tableChildNameList = element.split('&')
  1020. // 判断是否能拆分两个字符,子表标识和子表数据库名称
  1021. if (tableChildNameList.length == 2) {
  1022. i++
  1023. let childName = tableChildNameList[1] // 子表数据库名称
  1024. if (!formData.table_name_children) {
  1025. // 第一次拼接
  1026. formData.table_name_children = childName // 表名
  1027. } else {
  1028. // 后面的表明拼接用“,”隔开
  1029. formData.table_name_children = formData.table_name_children + ',' + childName // 表名
  1030. }
  1031. // 定义属性名和值
  1032. formData['childFiledNames' + i] = _.keys(formData[element][0]).join(',') // 子表字段名
  1033. formData['childList' + i] = JSON.stringify(formData[element]) // 子表数据
  1034. ischild = true
  1035. }
  1036. } else {
  1037. // 如果不是子表则是上传文件,则转字符串
  1038. formData[element] = JSON.stringify(formData[element])
  1039. }
  1040. }
  1041. // formData[element];
  1042. })
  1043. // 判断需不需要存子表
  1044. if (ischild) {
  1045. formData.filedNames = formData.filedNames + ',table_name_children'
  1046. }
  1047. console.log(formData)
  1048. // 子表数据
  1049. // 调用保存接口
  1050. this.btndisabled = true
  1051. this.todoManageOperationObject.formData = formData
  1052. this.todoManageOperationObject.url = url
  1053. // 获取是否部门负责人
  1054. formData.filedNames = formData.filedNames + ',is_leaders'
  1055. // formData.is_leaders = this.$store.getters.userInfo.identity
  1056. formData.is_leaders = this.$store.getters.userInfo.isPossess
  1057. // 清除子表规则的属性
  1058. _.keys(formData).forEach(r => {
  1059. if (r.indexOf('child&') != -1) {
  1060. delete formData[r]
  1061. }
  1062. })
  1063. // 如果手机端子表得则需要修改json
  1064. // var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
  1065. var jsonPamats = JSON.parse(JSON.stringify(this.jsonDataSave))
  1066. if (!this.isSJ && this.isNew) {
  1067. jsonPamats = null
  1068. }
  1069. this.todoManageOperationObject.jsonData = jsonPamats
  1070. })
  1071. .catch(err => {
  1072. console.log(err, '校验失败')
  1073. // resolve(false);
  1074. })
  1075. // })
  1076. },
  1077. close () {
  1078. this.$emit('close')
  1079. },
  1080. getData () {
  1081. // 通过函数获取数据
  1082. this.$refs.KFB.getData()
  1083. .then(res => {
  1084. // 获取数据成功
  1085. alert(JSON.stringify(res))
  1086. })
  1087. .catch(err => {
  1088. console.log(err, '校验失败')
  1089. })
  1090. },
  1091. // 刷新待办列表
  1092. refreshToDo () {
  1093. this.close()
  1094. this.$emit('getDataList')
  1095. },
  1096. itemData (res) {
  1097. var childName = '' // 子表规则名称
  1098. var itemIndex = 0
  1099. this.jsonData.list.forEach((element, index) => {
  1100. if (element.label.indexOf('child&') != -1) {
  1101. childName = element.label // 获取规则名
  1102. itemIndex = itemIndex + 1
  1103. }
  1104. })
  1105. var itemList = [] // 封装子表数据
  1106. for (var i = 1; i <= itemIndex; i++) {
  1107. var itemObject = {} // 子表对象
  1108. this.itemModelNameList.forEach(name => {
  1109. // 获取子表得值和封装对象
  1110. itemObject[name] = res[name + '@' + i]
  1111. delete res[name + '@' + i]
  1112. })
  1113. itemList.push(itemObject)
  1114. }
  1115. res[childName] = itemList // 完成子表数据封装
  1116. console.log(res)
  1117. },
  1118. deleteRow (idIndex) {
  1119. // 删除
  1120. this.jsonData.list.splice(idIndex, 1)
  1121. // 删除掉得json之后 重新处理model 和value
  1122. let childIndex = 0
  1123. this.jsonData.list.forEach((element, index) => {
  1124. if (element.label.indexOf('child&') != -1) {
  1125. childIndex = childIndex + 1
  1126. // 只有当前删除的对象json的后面对象json才进行修改
  1127. if (index >= idIndex) {
  1128. // 修改删除按钮的index
  1129. element.columns[0].list[1].options.defaultValue =
  1130. '<a href="javascript:void(0);" \n onclick="deleteRow(' + childIndex + ')">删除</a>'
  1131. // 修改model
  1132. updateModel(element, childIndex)
  1133. // 需要调整的子表值
  1134. var updateModelObject = {}
  1135. // 修改value
  1136. this.$refs.KFB.getData().then(res => {
  1137. // 根据原始字段名拼接带规则的
  1138. this.itemModelNameList.forEach(modelName => {
  1139. updateModelObject[modelName + '@' + childIndex] = res[modelName + '@' + (childIndex + 1)]
  1140. })
  1141. this.$refs.KFB.setData(updateModelObject)
  1142. })
  1143. }
  1144. }
  1145. })
  1146. console.log(JSON.stringify(this.jsonData.list))
  1147. },
  1148. add () {
  1149. let childLable = '' // 子表json标题
  1150. let childValue = {} // 新增子表json
  1151. let isReturn = false
  1152. let childIndex = 0
  1153. var itemList = []
  1154. this.jsonData.list.forEach((element, index) => {
  1155. if (element.label.indexOf('child&') != -1) {
  1156. childValue = JSON.parse(JSON.stringify(element))
  1157. childLable = element.label
  1158. // 处理删除按钮
  1159. childIndex = childIndex + 1
  1160. // element.columns[0].list[1].options.dynamicFun = 'delete' + childIndex
  1161. console.log(element.columns[0].list[1].options)
  1162. element.columns[0].list[1].options.defaultValue =
  1163. '<a href="javascript:void(0);" \n onclick="deleteRow(' + childIndex + ')">删除</a>'
  1164. updateModel(childValue, childIndex)
  1165. }
  1166. if (!isReturn && childLable != '' && element.label != childLable) {
  1167. isReturn = true
  1168. // 处理删除按钮
  1169. childIndex = childIndex + 1
  1170. // childValue.columns[0].list[1].options.dynamicFun = 'delete' + childIndex
  1171. childValue.columns[0].list[1].options.defaultValue =
  1172. '<a href="javascript:void(0);" \n onclick="deleteRow(' + childIndex + ')">删除</a>'
  1173. updateModel(childValue, childIndex)
  1174. // this.jsonData.list.splice(index, 0, childValue)
  1175. itemList.push(childValue)
  1176. }
  1177. itemList.push(element)
  1178. })
  1179. this.jsonData.list = itemList
  1180. console.log(JSON.stringify(this.jsonData.list))
  1181. },
  1182. // 把整个子表json的model进行规则修改
  1183. async listUpdateModel () {
  1184. let modelIndex = 0 // 子表model自增
  1185. // 循环整个json的表单
  1186. this.jsonData.list.forEach((element, index) => {
  1187. // 找到为子表的json
  1188. if (element.label.indexOf('child&') != -1) {
  1189. this.isSJ = true
  1190. // 获取子表原始得model字段名
  1191. if (modelIndex == 0) {
  1192. var i = 1
  1193. var itemString = JSON.stringify(element)
  1194. var itemModelNameList = [] // 储存子表字段名
  1195. for (var i = 1; i !== -1;) {
  1196. // 动态字符位置
  1197. i = itemString.indexOf('"model"', i)
  1198. if (i !== -1) {
  1199. // 从指定字符的周后一个字符后开始找(")
  1200. var ihStart = itemString.indexOf('"', i + 7)
  1201. // 再从 (") 后面位置还是找下一个 (")
  1202. var ihEnd = itemString.indexOf('"', ihStart + 1)
  1203. // 获取引号之间的字符
  1204. var model = itemString.substring(ihStart + 1, ihEnd)
  1205. // 如果动态表示不为空则获取
  1206. if (model != '') {
  1207. if (model.indexOf('@') != -1) {
  1208. model = model.substring(0, model.length - 2)
  1209. }
  1210. itemModelNameList.push(model)
  1211. }
  1212. i = ihEnd + 1
  1213. }
  1214. }
  1215. this.itemModelNameList = itemModelNameList
  1216. }
  1217. modelIndex = modelIndex + 1
  1218. // 修改model
  1219. updateModel(element, modelIndex)
  1220. }
  1221. })
  1222. },
  1223. //计算时间差
  1224. timeDifference(start, end,state){
  1225. // if(start>end){
  1226. // this.$message.error('起始时间不可大于结束时间');
  1227. // }else{
  1228. let beginTime = (new Date(start).getTime()) / 1000;
  1229. let endTime = (new Date(end).getTime()) / 1000;
  1230. //计算天数
  1231. var timediff = endTime - beginTime;
  1232. var days = parseInt(timediff / 86400); //60*60*24
  1233. //计算小时数
  1234. var remain = timediff % 86400 ;
  1235. var hours = parseInt(remain / 3600);
  1236. //计算分钟数
  1237. var remain = remain % 3600;
  1238. var mins = parseInt(remain / 60);
  1239. var res = days + '天' + hours + '小时' + mins + '分';
  1240. if(state == 'min'){
  1241. return days*24*60+hours*60+mins
  1242. }else if(state == 'hour'){
  1243. return days*24+hours+mins/60
  1244. }else if(state == 'day'){
  1245. if(start.split(' ').length==1 && end.split(' ').length == 1){
  1246. return days+1+hours/24+mins/60/24
  1247. }else{
  1248. return days+hours/24+mins/60/24
  1249. }
  1250. }else if(state == 'day/hour/min'){
  1251. return days+'天'+hours+'小时'+mins+'分'
  1252. }else if(state == 'hour/min'){
  1253. return (days*24+hours)+'小时'+mins+'分'
  1254. }
  1255. }
  1256. }
  1257. // }
  1258. }
  1259. // 获取主表字段,排除子表标识
  1260. function getFiledNames (formData) {
  1261. let filedNames = ''
  1262. let list = formData.filedNames.split(',') // 获取表单属性名集合
  1263. list.forEach(element => {
  1264. if (element.indexOf('&') == -1) {
  1265. // 查询是否有这个字段
  1266. if (filedNames == '') {
  1267. // 第一次则直接等于
  1268. filedNames = element
  1269. } else {
  1270. // 后面用逗号隔开
  1271. filedNames = filedNames + ',' + element
  1272. }
  1273. }
  1274. })
  1275. return filedNames
  1276. }
  1277. // 根据开始时间 结束时间计算天数
  1278. function startEndFun (start, end) {
  1279. let startTime = new Date(start)
  1280. let endTime = new Date(end)
  1281. if (startTime >= endTime) {
  1282. return 0
  1283. }
  1284. // 1,分钟取整
  1285. startTime = carryTime(startTime)
  1286. endTime = carryTime(endTime)
  1287. // 2,计算总天数
  1288. var totalTime = 0 // 工时,天数
  1289. if (startTime.getDay() == 6 || startTime.getDay() == 0) {
  1290. totalTime = endTime.getDate() - startTime.getDate()
  1291. } else {
  1292. totalTime = Math.floor((endTime - startTime) / (3600 * 1000) / 24)
  1293. }
  1294. // 3,拿初始值赋值给一个临时变量
  1295. var tempStartTime = new Date()
  1296. tempStartTime.setTime(startTime.getTime())
  1297. // 4,计算出总天数
  1298. while (tempStartTime.getDate() < endTime.getDate()) {
  1299. if (tempStartTime.getDay() == 6 || tempStartTime.getDay() == 0) {
  1300. // 周六或者周日减去
  1301. totalTime--
  1302. }
  1303. tempStartTime.setDate(tempStartTime.getDate() + 1)
  1304. }
  1305. // 5,计算出总小时数
  1306. var temp = 0 // 工时,小时
  1307. do {
  1308. if (startTime.getDay() == 6 || startTime.getDay() == 0) {
  1309. // 周六周日
  1310. startTime.setDate(startTime.getDate() + 1)
  1311. //* ********周六周日直接跳过,初始化为早晨9点
  1312. startTime.setHours(9)
  1313. startTime.setMinutes(0)
  1314. continue
  1315. }
  1316. if (endTime.getDay() == 6 || endTime.getDay() == 0) {
  1317. // 周六周日
  1318. endTime.setDate(endTime.getDate() + 1)
  1319. //* ********周六周日直接跳过,初始化为早晨9点
  1320. endTime.setHours(9)
  1321. endTime.setMinutes(0)
  1322. continue
  1323. }
  1324. let tempMinutes = startTime.getHours() * 60 + startTime.getMinutes()
  1325. // 上午9点到12点半,算工时
  1326. if (tempMinutes >= 9 * 60 && tempMinutes < 12 * 60) {
  1327. temp += 0.05
  1328. }
  1329. // 上午14点到18点半,算工时
  1330. if (tempMinutes >= 13 * 60 && tempMinutes < 18 * 60) {
  1331. temp += 0.05
  1332. }
  1333. startTime.setTime(startTime.getTime() + 0.5 * 3600 * 1000) // 每次增加半个小时
  1334. } while (startTime.getHours() * 60 + startTime.getMinutes() != endTime.getHours() * 60 + endTime.getMinutes())
  1335. {
  1336. totalTime += Math.floor(temp / 0.8)
  1337. totalTime += temp % 0.8
  1338. totalTime = Math.round(totalTime * 100) / 100
  1339. }
  1340. var days = Math.floor(totalTime)
  1341. var hours = Math.round((totalTime - days) * 100) / 10
  1342. console.log(days + '天', hours + '小时')
  1343. return days * 8 + hours
  1344. // if (start && end) {
  1345. // let startTime = new Date(start) // 开始时间
  1346. // let endTime = new Date(end) // 结束时间
  1347. // let usedTime = endTime - startTime // 相差的毫秒数
  1348. // let days = (usedTime / 1000 / 60 / 60).toFixed(2) // 计算出天数
  1349. // return days
  1350. // } else {
  1351. // return null
  1352. // }
  1353. }
  1354. // 格式化时间
  1355. function formatDate (date, fmt) {
  1356. if (/(y+)/.test(fmt)) {
  1357. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
  1358. }
  1359. let o = {
  1360. 'M+': date.getMonth() + 1,
  1361. 'd+': date.getDate(),
  1362. 'h+': date.getHours(),
  1363. 'm+': date.getMinutes(),
  1364. 's+': date.getSeconds()
  1365. }
  1366. for (let k in o) {
  1367. if (new RegExp(`(${k})`).test(fmt)) {
  1368. let str = o[k] + ''
  1369. fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : padLeftZero(str))
  1370. }
  1371. }
  1372. return fmt
  1373. }
  1374. function padLeftZero (str) {
  1375. return ('00' + str).substr(str.length)
  1376. }
  1377. /*
  1378. * 0-15分不算工时
  1379. * 15-45算半个小时
  1380. * 45-60算一个小时
  1381. * */
  1382. function carryTime (date) {
  1383. if (date.getMinutes() > 0 && date.getMinutes() < 15) {
  1384. date.setMinutes(0)
  1385. }
  1386. if (date.getMinutes() >= 15 && date.getMinutes() < 30) {
  1387. date.setMinutes(30)
  1388. }
  1389. if (date.getMinutes() > 30 && date.getMinutes() < 45) {
  1390. date.setMinutes(30)
  1391. }
  1392. if (date.getMinutes() >= 45) {
  1393. date.setHours(date.getHours() + 1)
  1394. date.setMinutes(0)
  1395. }
  1396. return date
  1397. }
  1398. // function
  1399. /**
  1400. * 修改model绑定值
  1401. */
  1402. function updateModel (object, childIndex) {
  1403. let keyString = _.keys(object).join(',')
  1404. if (keyString.indexOf('model') != -1) {
  1405. // 如果没有修改过则直接修改
  1406. if (object['model'].indexOf('@') == -1) {
  1407. object['model'] = object['model'] + '@' + childIndex
  1408. } else {
  1409. // 修改过则截取修改前的再进行修改
  1410. var m = object['model'].substring(0, object['model'].length - 2)
  1411. object['model'] = m + '@' + childIndex
  1412. }
  1413. }
  1414. // 递归
  1415. _.keys(object)
  1416. .join(',')
  1417. .split(',')
  1418. .forEach(l => {
  1419. if (object[l] instanceof Array) {
  1420. object[l].forEach(element => {
  1421. updateModel(element, childIndex)
  1422. })
  1423. }
  1424. })
  1425. }
  1426. </script>
  1427. <style lang="less" scoped>
  1428. @media print {
  1429. @page {
  1430. /* 横向 */
  1431. size: landscape;
  1432. /* 去除浏览器默认页眉页脚 */
  1433. margin: 0;
  1434. }
  1435. .noprint {
  1436. display: none;
  1437. }
  1438. /deep/.ant-input{
  1439. border: none !important;
  1440. }
  1441. /deep/ .ant-modal-header{
  1442. display: none !important;
  1443. }
  1444. /deep/ .ant-modal-content{
  1445. box-shadow:none !important
  1446. }
  1447. }
  1448. /deep/ .anticon-question-circle-o {
  1449. display: none !important;
  1450. }
  1451. </style>