demoForm2.vue 78 KB

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