demoForm2.vue 61 KB

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