demoForm2.vue 89 KB

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