demoForm2.vue 90 KB

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