demoForm2.vue 100 KB

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