demoForm2.vue 97 KB

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