demoForm2.vue 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884
  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-print="'#printContent'" ghost type="primary">打印</a-button>
  5. </div>
  6. <a-card :body-style="{ padding: '15px 32px' }" :bordered="false" id="printContent" :class="{'abcdefg':true}" >
  7. <!-- <div style="text-align: center;">
  8. <h3 v-print="'#printContent'" ghost title="点击此处,打印当前页面" >{{printTitle}}</h3>
  9. <br/>
  10. </div> -->
  11. <section ref="print" id="printContent" class="abcdefg">
  12. <!-- <a-form @submit="handleSubmit" :form="form">
  13. <a-form-item
  14. label="标题"
  15. :labelCol="{lg: {span: 7}, sm: {span: 7}}"
  16. :wrapperCol="{lg: {span: 10}, sm: {span: 17} }">
  17. <a-input :disabled="disabled"
  18. v-decorator="[
  19. 'name',
  20. {rules: [{ required: true, message: '请输入标题' }]}
  21. ]"
  22. name="name"
  23. placeholder="给目标起个名字" />
  24. </a-form-item>
  25. <a-form-item v-if="!disabled"
  26. :wrapperCol="{ span: 24 }"
  27. style="text-align: center"
  28. >
  29. <a-button htmlType="submit" type="primary" :disabled="disabled||btndisabled" @click="handleSubmit">保存</a-button>
  30. <a-button style="margin-left: 8px" :disabled="disabled" @click="close">取消</a-button>
  31. </a-form-item>
  32. </a-form>-->
  33. <k-form-build
  34. :value="jsonData"
  35. @change="handleChange"
  36. :dynamicData="dynamicData"
  37. ref="KFB"
  38. @submit="handleSubmit"
  39. />
  40. <div v-if="printTitleImg" style="text-align: right;margin-right: 13%">
  41. <!-- <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"/> -->
  42. <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"/>
  43. </div>
  44. </section>
  45. <div style="text-align:center">
  46. <a-button
  47. htmlType="submit"
  48. type="primary"
  49. :disabled="disabled || btndisabled"
  50. @click="handleSubmit"
  51. class="noprint"
  52. >保存</a-button>
  53. <todoManageOperation
  54. v-if="processData.operationType && processData.operationType == '1'"
  55. :processData="processData"
  56. :todoManageOperationObject="todoManageOperationObject"
  57. :disabled="disabled"
  58. :btndisabled="btndisabled"
  59. @refreshToDo="refreshToDo"
  60. @handleSubmit2="handleSubmit2"
  61. ></todoManageOperation>
  62. <a-button style="margin-left: 8px;" :disabled="disabled || disabled2" @click="close" class="noprint">取消</a-button>
  63. <!-- <a-button type="primary" v-if="printDisable" @click="changedd" class="noprint" style="margin-left:10px">打印</a-button> -->
  64. </div>
  65. </a-card>
  66. <personnel-files-modal ref="personnelFilesModal" @close="closeP"></personnel-files-modal>
  67. <fixed-zy-modal ref="FixedZyModal" @close="closeP"></fixed-zy-modal>
  68. <car-sq-modal ref="CarSqModal" @close="closeP"></car-sq-modal>
  69. <material-sl-modal ref="MaterialSlModal" @close="closeP"></material-sl-modal>
  70. </div>
  71. </template>
  72. <script>
  73. import pick from 'lodash.pick'
  74. import todoManageOperation from '../operation/todoManageOperation'
  75. import PersonnelFilesModal from './personnelFilesModal'
  76. import CarSqModal from './carSqModal'
  77. import MaterialSlModal from './materialSlModal'
  78. import FixedZyModal from './fixedZyModal'
  79. import { postAction, postFormDataAction} from '@/api/manage'
  80. import {annualLeave} from '@api/oa/cd-personnel-files'
  81. import moment from 'moment'
  82. import {getProjctName} from '../../../../url.config'
  83. import ACol from "ant-design-vue/es/grid/Col";
  84. import ARow from "ant-design-vue/es/grid/Row";
  85. import ATextarea from 'ant-design-vue/es/input/TextArea'
  86. export default {
  87. name: 'DemoForm',
  88. props: {
  89. reBizCode:{
  90. type: String,
  91. default: ''
  92. },
  93. /* 全局禁用,可表示查看 */
  94. disabled: {
  95. type: Boolean,
  96. default: false,
  97. required: false
  98. },
  99. /* 流程数据 */
  100. processData: {
  101. type: Object,
  102. default: () => {
  103. return {}
  104. },
  105. required: false
  106. },
  107. /* 是否新增 */
  108. isNew: { type: Boolean, default: false, required: false }
  109. },
  110. components: {
  111. ATextarea,
  112. ARow,
  113. ACol,
  114. todoManageOperation,
  115. moment,
  116. PersonnelFilesModal,
  117. FixedZyModal,
  118. CarSqModal,
  119. MaterialSlModal,
  120. },
  121. data () {
  122. return {
  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. if(this.processData.status == 2){
  529. this.printTitle = true;
  530. if(this.processData.businessTable == 'meeting_summary'){
  531. let leadership_pass = this.$refs.KFB.form.getFieldValue('leadership_pass');
  532. if(leadership_pass == 2){
  533. this.printTitleImg = false;
  534. }else{
  535. this.printTitleImg = true;
  536. }
  537. }else{
  538. this.printTitleImg = true;
  539. }
  540. }else{
  541. this.printTitleImg = false;
  542. this.printTitle = false;
  543. }
  544. } else {
  545. this.$message.error(res.message)
  546. }
  547. })
  548. })
  549. },
  550. //遍历help
  551. forHelp(obj){
  552. for(var a in obj){
  553. if (typeof(obj[a]) == "object"){
  554. if(obj[a].help !=='' && obj[a].help){
  555. //保存每一项的label和key
  556. this.cvarr.push({model:obj[a].model,key:obj[a].key,type:obj[a].type})
  557. obj[a].help = obj[a].help.split(',')
  558. //保存含有help的item中的label和help里的信息
  559. this.fArr=[
  560. {
  561. label:obj[a].model,
  562. value:'',
  563. },
  564. {
  565. label: obj[a].help[0],
  566. value:'',
  567. },
  568. {
  569. label: obj[a].help[1],
  570. value:'',
  571. },
  572. {
  573. label: obj[a].help[2],
  574. value:'',
  575. },
  576. ]
  577. //保存多各含有help的数据
  578. this.bv.push({bn:this.fArr})
  579. //默认当天时间
  580. this.defualtData(this.fArr)
  581. }else if(obj[a].help ==''){
  582. this.cvarr.push({model:obj[a].model,key:obj[a].key,type:obj[a].type})
  583. }else if(obj[a].type == 'button'){
  584. this.buttonArr.push(obj[a])
  585. this.buttonShow(obj[a])
  586. }
  587. this.forHelp(obj[a])
  588. }
  589. }
  590. },
  591. buttonShow(obj){
  592. if(obj.label == '打印'){
  593. this.printDisable = true
  594. }
  595. },
  596. //默认时间/默认当前账号
  597. defualtData(item){
  598. if(item[1].label =='today'){
  599. if(item[2].label){
  600. item[0].value =moment(new Date().toLocaleDateString()).format('YYYY-MM-DD')
  601. }else{
  602. item[0].value =moment(new Date().toLocaleDateString()).format('YYYY-MM-DD HH:mm')
  603. }
  604. var that = this
  605. setTimeout(function(){
  606. that.$refs.KFB.setData({[item[0].label]:item[0].value})
  607. },0)
  608. }else if(item[1].label =='user'){
  609. this.$store.getters.userInfo
  610. var that = this
  611. setTimeout(function(){
  612. that.$refs.KFB.setData({[item[0].label]:that.$store.getters.userInfo.realname})
  613. // 森语-请假单-须根据当前用户带出剩余年假
  614. if(that.processData.businessTable =='employee_leave'){
  615. annualLeave({username:that.$store.getters.userInfo.username}).then(res => {
  616. if (res.success) {
  617. that.leave = res.result.nannualNowNum
  618. that.$refs.KFB.setData({leave_remaining: that.leave})
  619. }
  620. })
  621. }
  622. var jnDeparment = ''
  623. if(getProjctName() =='技能博物馆'){ //获取技能博物馆登录人对应的部门
  624. that.dynamicData.personListJn.map(item =>{
  625. if(item.label == that.$store.getters.nickname){
  626. jnDeparment = item.departIds_dictText
  627. }
  628. })
  629. }
  630. if(that.processData.businessTable == 'regular_employee_apply'){//员工转正申请
  631. that.$refs.KFB.setData({apply_department:that.deptInfo[that.$store.getters.userInfo.username]})
  632. // that.$refs.KFB.setData({job_title:that.postInfo[that.$store.getters.userInfo.username]})
  633. }
  634. if(that.processData.businessTable == 'seal_apply'){//用印申请单
  635. that.$refs.KFB.setData({apply_department:that.deptInfo[that.$store.getters.userInfo.username]})
  636. }
  637. if(that.processData.businessTable == 'separation_application'){//离职申请
  638. that.$refs.KFB.setData({job_title:that.postInfo[that.$store.getters.userInfo.username]})
  639. }
  640. if(that.processData.businessTable == 'bwg_house_duty'){ // 技能博物馆--全馆值班 --默认当前登陆人
  641. that.$refs.KFB.setData({referrer:that.$store.getters.nickname})
  642. that.dynamicData.personListJn.map(item =>{
  643. if(item.label == that.$store.getters.nickname){
  644. that.$refs.KFB.setData({department_id:item.departIds})
  645. that.$refs.KFB.setData({department_name:item.departIds_dictText})
  646. that.$refs.KFB.setData({mobile_telephone:item.phone})
  647. that.$refs.KFB.setData({telephone:item.telephone})
  648. }
  649. })
  650. }
  651. if(that.processData.businessTable == 'bwg_meeting_summary'){//技能博物馆 --- 会议纪要---默认当前登陆人
  652. that.dynamicData.personListJn.map(item =>{
  653. if(item.label == that.$store.getters.nickname){
  654. that.$refs.KFB.setData({record_person:item.value})
  655. that.$refs.KFB.setData({record_department:item.departIds_dictText})
  656. }
  657. })
  658. }
  659. //技能博物馆-物料库存
  660. if(that.processData.businessTable == 'material_apply'){
  661. that.$refs.KFB.setData({department:jnDeparment})
  662. }
  663. //技能博物馆-物料申领
  664. if(that.processData.businessTable == 'application_form'){
  665. that.$refs.KFB.setData({department:jnDeparment})
  666. }
  667. //技能博物馆-任务--默认当前登陆人部门
  668. if(that.processData.businessTable == 'task_management'){
  669. that.$refs.KFB.setData({initiate_department:jnDeparment})
  670. }
  671. //技能博物馆-固定资产-报废
  672. if(that.processData.businessTable == 'scrap_apply'){
  673. that.$refs.KFB.setData({apply_personnel_department:jnDeparment})
  674. }
  675. },0)
  676. annualLeave({username:that.$store.getters.userInfo.username}).then(res => {
  677. if (res.success) {
  678. this.leave = res.result.nannualNowNum
  679. }else{
  680. this.$message.error(res.message);
  681. }
  682. })
  683. }else if(item[1].label =='automatic'){
  684. var that = this
  685. setTimeout(function(){
  686. if(that.processData.businessTable == 'incident_ticket'){ // 森语-质量事故单-自动生成事故单号
  687. if( that.processData.tableId==''|| !that.processData.tableId){
  688. that.getAction('/sys/user/getNextNo',{name:'accidentCode'}).then(res => {
  689. that.$refs.KFB.setData({accident_number:res})
  690. })
  691. }
  692. }
  693. },200)
  694. }
  695. },
  696. // 获取申请人信息
  697. getApplicant () {
  698. console.log('aa', this.$refs.KFB.form.getFieldValue('applicant'))
  699. // if (this.$refs.KFB.form.getFieldValue('applicant')) {
  700. // alert(1)
  701. // this.$refs.KFB.setData({
  702. // applicant: this.$store.getters.userInfo.username
  703. // })
  704. // }
  705. },
  706. changedd(){
  707. window.print()
  708. },
  709. //主子表计算
  710. tableCalculation(value){
  711. if(this.processData.businessTable == 'supplieses_apply_a' ){
  712. var number1 = 0,
  713. number2 = 0
  714. //寻找help信息中对应的modol值
  715. this.bv.map(item=>{
  716. this.cvarr.map(vv=>{
  717. if(vv.key == item.bn[1].label){
  718. number1 = vv.model
  719. }else if(vv.key == item.bn[2].label){
  720. number2 = vv.model
  721. }
  722. })
  723. //表中每一行分别计算
  724. var sum = 0
  725. value.map(b=>{
  726. b[item.bn[0].label] = b[number1]*b[number2]
  727. sum += b[item.bn[0].label] //计算出表格内的总价总和
  728. if(this.$store.getters.nickname=='崔崇杰'){
  729. b['procurement_type']='1'
  730. }else{
  731. b['procurement_type']='2'
  732. }
  733. })
  734. this.$refs.KFB.setData({sum:sum})
  735. })
  736. }
  737. if(this.processData.businessTable == 'incident_ticket'){
  738. var all = 0,
  739. currencys=[],
  740. currency =''
  741. value.map(item=>{
  742. item.accident_sum = item.accident_sum?item.accident_sum:'0'
  743. //计算表头总价
  744. all+=Number(item.accident_sum)
  745. //币种-自动带出
  746. if(item.money_type){currencys.push(item.money_type)}
  747. })
  748. //获取表格中只出现一次的币种-即为改变的币种
  749. currencys.every(item=>{
  750. const countOccurences = (arr, value) => arr.reduce((a, v) => v === value ? a + 1 : a + 0, 0)
  751. if(countOccurences(currencys,item)==1){
  752. currency=item
  753. return false
  754. }
  755. return true
  756. })
  757. //赋值
  758. value.map(item=>{
  759. //若无只出现一次的币种 1.第一次表格增行 2.表格中有两条以上数据,再次增行
  760. if(currency==''){
  761. item.money_type = currencys[0]
  762. }else{
  763. item.money_type = currency
  764. }
  765. })
  766. this.$refs.KFB.setData({total_money:all})
  767. }
  768. },
  769. specialTerms(value,key){
  770. var that = this
  771. //剩余年假
  772. if(key == 'employe_name'){
  773. setTimeout(function(){
  774. annualLeave({username:value}).then(res => {
  775. if (res.success) {
  776. //选择姓名获取页面的请假类型和时间间隔
  777. that.leave = res.result.nannualNowNum
  778. that.$refs.KFB.setData({leave_remaining: that.leave})
  779. var category = that.$refs.KFB.form.getFieldValue('leave_category')
  780. var time1 = that.$refs.KFB.form.getFieldValue('start_date')
  781. var time2 = that.$refs.KFB.form.getFieldValue('end_date')
  782. var timeC=that.timeDifference(time1,time2,'min') //获取时间差
  783. //事假,超过180分钟,年假大于0.5
  784. if(category == '事假' &&timeC>=180&&that.leave>=0.5){
  785. that.$refs.KFB.setData({unit:'天'})
  786. that.$refs.KFB.setData({leave_category:'年假'})
  787. }else if(category == '年假' && that.leave<0.5){ //类型为年假,剩余年假小于0.5
  788. that.$refs.KFB.setData({unit:'分'})
  789. that.$refs.KFB.setData({leave_category:''})
  790. that.$message.error('剩余年假不足!');
  791. }
  792. }else{
  793. that.$message.error(res.message);
  794. }
  795. })
  796. },0)
  797. }
  798. //请假类型与单位
  799. //事假
  800. if(key == 'leave_category' && value == '事假'){
  801. setTimeout(function(){
  802. var time1 = that.$refs.KFB.form.getFieldValue('start_date')
  803. var time2 = that.$refs.KFB.form.getFieldValue('end_date')
  804. var timeC=that.timeDifference(time1,time2,'min') //获取时间差
  805. if(timeC>=180 && that.leave>=0.5){ //事假,时间差大于180,剩余年假大于0.5
  806. that.$refs.KFB.setData({unit:'天'})
  807. that.$refs.KFB.setData({leave_category:'年假'})
  808. }else{
  809. that.$refs.KFB.setData({unit:'分'})
  810. }
  811. },0)
  812. }else if(key == 'leave_category' && value == '病假'){ //病假
  813. setTimeout(function(){
  814. that.$refs.KFB.setData({unit:'分'})
  815. },0)
  816. }else if(key == 'leave_category' && value == '年假'){//年假
  817. setTimeout(function(){
  818. if(that.leave >=0.5){ //剩余年假大于0.5
  819. that.$refs.KFB.setData({unit:'天'})
  820. }else{ //剩余年假小于0.5
  821. that.$refs.KFB.setData({unit:'分'})
  822. that.$refs.KFB.setData({leave_category:''})
  823. that.$message.error('剩余年假不足!');
  824. }
  825. },0)
  826. }else if(key == 'leave_category'){
  827. setTimeout(function(){
  828. that.$refs.KFB.setData({unit:'天'})
  829. },0)
  830. }
  831. //时间间隔和类型
  832. if(key =='start_date' || key =='end_date'){
  833. setTimeout(function(){
  834. var time2 = that.$refs.KFB.form.getFieldValue('end_date')
  835. var time1 = that.$refs.KFB.form.getFieldValue('start_date')
  836. var timeC=that.timeDifference(time1,time2,'min')
  837. var lx=that.$refs.KFB.form.getFieldValue('leave_category')
  838. if(timeC>=180&&lx=='事假'&&that.leave>=0.5){ //事假,时间差大于180,剩余年假大于0.5
  839. that.$refs.KFB.setData({unit:'天'})
  840. that.$refs.KFB.setData({leave_category:'年假'})
  841. }
  842. },0)
  843. }
  844. },
  845. // 表单字段数值发生改变事件
  846. handleChange (value, key) {
  847. // debugger
  848. if(key == 'proposer' && this.processData.businessTable == 'regular_employee_apply'){//员工转正申请:申请人部门
  849. this.$refs.KFB.setData({apply_department:this.deptInfo[value]})
  850. }
  851. if(key == 'regular_employee' && this.processData.businessTable == 'regular_employee_apply'){//员工转正申请:转正人员岗位
  852. this.$refs.KFB.setData({job_title:this.postInfo[value]})
  853. }
  854. if(key == 'proposer' && this.processData.businessTable == 'seal_apply'){//用印申请单
  855. this.$refs.KFB.setData({apply_department:this.deptInfo[value]})
  856. }
  857. if(key == 'employee_name' && this.processData.businessTable == 'separation_application'){//离职申请
  858. this.$refs.KFB.setData({job_title:this.postInfo[value]})
  859. }
  860. //森语-质量事故单
  861. if(key=='child&incident_ticket_children'){
  862. this.tableCalculation(value)
  863. }
  864. //技能博物馆-----退休录入
  865. if(key == 'name' && this.processData.businessTable == 'bwg_retire_input'){//技能博物馆 ---- 退休录入
  866. this.dynamicData.personListJn.map(item =>{
  867. if(item.label == value){
  868. this.$refs.KFB.setData({employee_number:item.workNo})
  869. this.$refs.KFB.setData({post:item.post})
  870. this.$refs.KFB.setData({rz_date:item.nInductionTim})
  871. }
  872. })
  873. // this.$refs.KFB.setData({employee_number:this.postInfo[value]})
  874. }
  875. //技能博物馆-----离职录入
  876. if(key == 'name' && this.processData.businessTable == 'bwg_quit_input'){//技能博物馆 ---- 退休录入
  877. this.dynamicData.personListJn.map(item =>{
  878. if(item.label == value){
  879. this.$refs.KFB.setData({employee_number:item.workNo})
  880. this.$refs.KFB.setData({post:item.post})
  881. this.$refs.KFB.setData({rz_date:item.nInductionTim})
  882. }
  883. })
  884. }
  885. //技能博物馆 ----- 费用报销
  886. if(key == 'expense_person' && this.processData.businessTable == 'bwg_expense_apply'){
  887. this.dynamicData.personListJn.map(item =>{
  888. if(item.label == value){
  889. this.$refs.KFB.setData({expense_department:item.departIds_dictText})
  890. }
  891. })
  892. }
  893. // 技能博物馆---用车申请
  894. if(key == 'car_automobilist' && this.processData.businessTable == 'car_apply'){
  895. this.dynamicData.personListJn.map(item =>{
  896. if(item.label == value){
  897. this.$refs.KFB.setData({car_department:item.departIds_dictText})
  898. }
  899. })
  900. }
  901. // // 技能博物馆---物料库存--金额计算
  902. // if((key == 'unit_price'||key=='amount') && this.processData.businessTable == 'material_apply'){
  903. // var that = this
  904. // setTimeout(function(){
  905. // var unit_price = that.$refs.KFB.form.getFieldValue('unit_price'),
  906. // amount = that.$refs.KFB.form.getFieldValue('amount'),
  907. // sum = Number(unit_price)*Number(amount)
  908. // that.$refs.KFB.setData({money:sum})
  909. // },0)
  910. // }
  911. // 技能博物馆---物料库存--部门
  912. if(key == 'input_account' && this.processData.businessTable == 'material_apply'){
  913. this.dynamicData.personListJn.map(item =>{
  914. if(item.label == value){
  915. this.$refs.KFB.setData({department:item.departIds_dictText})
  916. }
  917. })
  918. }
  919. if(key == 'task_executor' &&this.processData.businessTable == 'task_management'){
  920. this.dynamicData.personListJn.map(item =>{
  921. if(item.label == value){
  922. this.$refs.KFB.setData({task_department:item.departIds_dictText})
  923. }
  924. })
  925. }
  926. // 技能博物馆---物料申领--部门
  927. if(key == 'get_account' && this.processData.businessTable == 'application_form'){
  928. this.dynamicData.personListJn.map(item =>{
  929. if(item.label == value){
  930. this.$refs.KFB.setData({department:item.departIds_dictText})
  931. }
  932. })
  933. }
  934. // 技能博物馆---固定资产--归还
  935. if(key == 'uuse_personnel' && this.processData.businessTable == 'give_back'){
  936. this.dynamicData.personListJn.map(item =>{
  937. if(item.label == value){
  938. this.$refs.KFB.setData({use_department:item.departIds_dictText})
  939. }
  940. })
  941. }
  942. //技能博物馆-固定资产-报废
  943. if(key == 'apply_personnel' &&this.processData.businessTable == 'scrap_apply'){
  944. this.dynamicData.personListJn.map(item =>{
  945. if(item.label == value){
  946. this.$refs.KFB.setData({apply_personnel_department:item.departIds_dictText})
  947. }
  948. })
  949. }
  950. //技能博物馆 ----资金审批
  951. if(key == 'project_name' && this.processData.businessTable == 'bwg_capital_approval'){
  952. this.dynamicData.fundApproval.map(item =>{
  953. if(item.label == value){
  954. this.$refs.KFB.setData({start_data:item.startDate})
  955. this.$refs.KFB.setData({end_date:item.endDate})
  956. this.$refs.KFB.setData({project_reasons:item.projectReasons})
  957. this.$refs.KFB.setData({budget_information:item.budgetInformation})
  958. }
  959. })
  960. }
  961. //改变的表单是主子表类型时----物质申请单
  962. if(key =='child&supplieses_apply'){
  963. this.tableCalculation(value)
  964. }
  965. //特别字段
  966. this.specialTerms(value,key)
  967. //代码赘余,日后维护
  968. //保存发生改变字段名对应的key
  969. var cc ='',
  970. type = ''
  971. this.cvarr.map(k =>{
  972. if(k.model ==key){
  973. cc=k.key
  974. type = k.type
  975. }})
  976. //根据数值改变计算
  977. var that =this
  978. setTimeout(function(){
  979. that.bv.map(event =>{
  980. if(event.bn[1].label == cc || event.bn[2].label == cc){
  981. that.cvarr.map(k=>{
  982. if(k.key == event.bn[1].label){
  983. event.bn[1].value = that.$refs.KFB.form.getFieldValue(k.model)
  984. }else if(k.key == event.bn[2].label){
  985. event.bn[2].value = that.$refs.KFB.form.getFieldValue(k.model)
  986. }
  987. })
  988. if(type == 'date'){
  989. if(event.bn[1].value!=='' && event.bn[2].value!==''){
  990. var state = ''
  991. state = event.bn[3].label
  992. event.bn[0].value = that.timeDifference(event.bn[1].value,event.bn[2].value,state)
  993. }
  994. }else{
  995. if(event.bn[3].label =="+"){
  996. event.bn[0].value = Number(event.bn[1].value)+Number(event.bn[2].value)
  997. }else if(event.bn[3].label =="-"){
  998. event.bn[0].value = Number(event.bn[1].value)-Number(event.bn[2].value)
  999. }else if(event.bn[3].label =="*"){
  1000. event.bn[0].value = Number(event.bn[1].value)*Number(event.bn[2].value)
  1001. }
  1002. }
  1003. that.$refs.KFB.setData({[event.bn[0].label]:event.bn[0].value})
  1004. }
  1005. })
  1006. },0)
  1007. // // 数据变化时触发
  1008. // // 如果开始时间发生变化
  1009. // if (key == 'start_time') {
  1010. // // 判断结束时间是否存在
  1011. // if (this.$refs.KFB.form.getFieldValue('end_time')) {
  1012. // // 获取时间差
  1013. // let duration = startEndFun(value, this.$refs.KFB.form.getFieldValue('end_time'))
  1014. // if (duration) {
  1015. // // 使用k-form-design组件的form属性修改表单数据
  1016. // this.$refs.KFB.setData({
  1017. // duration: duration
  1018. // })
  1019. // }
  1020. // }
  1021. // }
  1022. // // 如果结束时间发生变化
  1023. // if (key == 'end_time') {
  1024. // // 判断结束时间是否存在
  1025. // if (this.$refs.KFB.form.getFieldValue('start_time')) {
  1026. // // 获取时间差
  1027. // let duration = startEndFun(this.$refs.KFB.form.getFieldValue('start_time'), value)
  1028. // if (duration) {
  1029. // // 使用k-form-design组件的form属性修改表单数据
  1030. // this.$refs.KFB.setData({
  1031. // duration: duration
  1032. // })
  1033. // }
  1034. // }
  1035. // }
  1036. },
  1037. // handler
  1038. handleSubmit (e) {
  1039. var that =this
  1040. // return new Promise((resolve)=>{
  1041. // 通过函数获取数据
  1042. this.$refs.KFB.getData()
  1043. .then(res => {
  1044. let formData1 = JSON.parse(JSON.stringify(res))
  1045. // 获取数据成功
  1046. let formData = JSON.parse(JSON.stringify(res))
  1047. var addForm = 'no'
  1048. if(this.processData.businessTable == 'employee_leave'){
  1049. var estimate = this.$refs.KFB.form.getFieldValue('leave_days'),
  1050. // actual = that.$refs.KFB.form.getFieldValue('practical_leave'),
  1051. leaveCategory = this.$refs.KFB.form.getFieldValue('leave_category')
  1052. if(leaveCategory=='年假' && !estimate){
  1053. this.$message.error('请填写预计请假天数!')
  1054. addForm = 'yes'
  1055. }
  1056. if(estimate>this.leave && leaveCategory=='年假'){
  1057. this.$message.error('预计请假年假'+estimate+'大于剩余年假'+this.leave)
  1058. addForm = 'yes'
  1059. }
  1060. }
  1061. if(this.processData.businessTable == 'incident_ticket'){
  1062. var sonTable=[]
  1063. // 获取子表数据
  1064. _.keys(formData1).forEach(r => {
  1065. if (r.indexOf('child&') != -1) {
  1066. sonTable=formData1[r]
  1067. }
  1068. })
  1069. var all = 0,
  1070. PlanNum=[]
  1071. sonTable.map(item=>{
  1072. item.accident_sum = item.accident_sum?item.accident_sum:'0'
  1073. all+= Number(item.accident_sum)
  1074. PlanNum.push(item.plan_number)
  1075. })
  1076. formData.total_money = all
  1077. formData.plan_number = PlanNum.toString()
  1078. sonTable.every(item=>{
  1079. if(item.accident_type=='不涉及金额' && item.accident_sum !=='0'){
  1080. this.$message.error('事故类型为不涉及金额时事故金额应为0!')
  1081. item.accident_sum = item.accident_sum
  1082. addForm = 'yes'
  1083. return false
  1084. }
  1085. return true
  1086. })
  1087. var supplier = this.$refs.KFB.form.getFieldValue('responsibility_company')
  1088. var responsibility1 = this.$refs.KFB.form.getFieldValue('responsibility_person1')
  1089. if(sonTable.length==0){
  1090. this.$message.error('计划单号未填写!')
  1091. addForm = 'yes'
  1092. }else{
  1093. if((!supplier||supplier=='') && (!responsibility1 || responsibility1=='')){
  1094. this.$message.error('责任人和责任单位必填其一')
  1095. addForm = 'yes'
  1096. }
  1097. if(supplier&&supplier!==''){
  1098. var type = this.$refs.KFB.form.getFieldValue('business_type')
  1099. var factory = this.$refs.KFB.form.getFieldValue('factory_signature')
  1100. if(!type|| type==''){
  1101. this.$message.error('请选择业务类型')
  1102. // 边框变红
  1103. let div1 = document.getElementById('business_type')
  1104. div1.setAttribute('class', 'active')
  1105. addForm = 'yes'
  1106. }else if(!factory || factory==''){
  1107. sonTable.every(item=>{
  1108. if(item.accident_type=='扣款'){
  1109. this.$message.error('请上传工厂签章')
  1110. addForm = 'yes'
  1111. return false
  1112. }
  1113. return true
  1114. })
  1115. }
  1116. }
  1117. if(responsibility1&&responsibility1!==''){
  1118. var responsibility2 = this.$refs.KFB.form.getFieldValue('responsibility_person2')
  1119. var responsibility3 = this.$refs.KFB.form.getFieldValue('responsibility_person3')
  1120. var responsibility4 = this.$refs.KFB.form.getFieldValue('responsibility_person4')
  1121. var sum1 = this.$refs.KFB.form.getFieldValue('sum1')
  1122. var sum2 = this.$refs.KFB.form.getFieldValue('sum2')
  1123. var sum3 = this.$refs.KFB.form.getFieldValue('sum3')
  1124. var sum4 = this.$refs.KFB.form.getFieldValue('sum4')
  1125. var dd =[
  1126. {responsibility:responsibility1,sum:sum1,index:1},
  1127. {responsibility:responsibility2,sum:sum2,index:2},
  1128. {responsibility:responsibility3,sum:sum3,index:3},
  1129. {responsibility:responsibility4,sum:sum4,index:4},
  1130. ]
  1131. dd.every(item=>{
  1132. if((item.responsibility&&item.responsibility!=='') && (!item.sum|| item.sum=='')){
  1133. this.$message.error('请填写金额'+item.index)
  1134. addForm = 'yes'
  1135. return false
  1136. }
  1137. return true
  1138. })
  1139. }
  1140. }
  1141. }
  1142. // 处理手机端子表数据
  1143. if (this.isSJ) {
  1144. this.itemData(res)
  1145. }
  1146. // 清除为空的表单数据
  1147. _.keys(res).forEach(r => {
  1148. if (!res[r]) {
  1149. delete res[r]
  1150. }
  1151. })
  1152. console.log(formData)
  1153. formData.id = this.data.id
  1154. formData.procDefId = this.processData.id
  1155. formData.procDeTitle = this.processData.name
  1156. if (!formData.tableName) formData.tableName = this.processData.businessTable
  1157. formData.filedNames = _.keys(res).join(',')
  1158. formData.filedNames = getFiledNames(formData) // 获取主表字段,排除子表标识
  1159. var url = this.url.addApply
  1160. if (!this.isNew) {
  1161. url = this.url.editForm
  1162. }
  1163. // 是否存在子表
  1164. let ischild = false
  1165. // 循环表单字段属性判断是否属性中包含数组对象
  1166. let i = 0 // 子表数量
  1167. _.keys(res)
  1168. .join(',')
  1169. .split(',')
  1170. .forEach(element => {
  1171. if (formData[element] instanceof Array) {
  1172. // 判断是否符合子表命名规则
  1173. if (element.indexOf('&') != -1) {
  1174. let tableChildNameList = element.split('&')
  1175. // 判断是否能拆分两个字符,子表标识和子表数据库名称
  1176. if (tableChildNameList.length == 2) {
  1177. i++
  1178. let childName = tableChildNameList[1] // 子表数据库名称
  1179. if (!formData.table_name_children) {
  1180. // 第一次拼接
  1181. formData.table_name_children = childName // 表名
  1182. } else {
  1183. // 后面的表明拼接用“,”隔开
  1184. formData.table_name_children = formData.table_name_children + ',' + childName // 表名
  1185. }
  1186. // 定义属性名和值
  1187. formData['childFiledNames' + i] = _.keys(formData[element][0]).join(',') // 子表字段名
  1188. formData['childList' + i] = JSON.stringify(formData[element]) // 子表数据
  1189. ischild = true
  1190. }
  1191. } else {
  1192. // 如果不是子表则是上传文件,则转字符串
  1193. formData[element] = JSON.stringify(formData[element])
  1194. }
  1195. }
  1196. // formData[element];
  1197. })
  1198. // 判断需不需要存子表
  1199. if (ischild) {
  1200. formData.filedNames = formData.filedNames + ',table_name_children'
  1201. }
  1202. console.log(formData)
  1203. // 子表数据
  1204. // 调用保存接口
  1205. this.todoManageOperationObject.formData = formData
  1206. this.todoManageOperationObject.url = url
  1207. // formData.jsonContent=JSON.stringify(this.jsonData).toString()
  1208. // 获取是否部门负责人
  1209. formData.filedNames = formData.filedNames + ',is_leaders'
  1210. // formData.is_leaders = this.$store.getters.userInfo.identity
  1211. formData.is_leaders = this.$store.getters.userInfo.isPossess
  1212. // 清除子表规则的属性
  1213. _.keys(formData).forEach(r => {
  1214. if (r.indexOf('child&') != -1) {
  1215. delete formData[r]
  1216. }
  1217. })
  1218. // 如果手机端子表得则需要修改json
  1219. // var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
  1220. var jsonPamats = JSON.parse(JSON.stringify(this.jsonDataSave))
  1221. if (!this.isSJ && this.isNew) {
  1222. jsonPamats = null
  1223. }
  1224. this.todoManageOperationObject.jsonData = jsonPamats
  1225. // 非我的待办节点打卡表单界面
  1226. if(addForm=='no'){
  1227. this.btndisabled = true
  1228. postFormDataAction(url, formData, { jsonContent: jsonPamats })
  1229. .then(res => {
  1230. if (res.success) {
  1231. this.todoManageOperationObject.isSave = true
  1232. this.$message.success('保存成功!')
  1233. console.log('123')
  1234. this.$emit('afterSubmit', formData)
  1235. this.$emit('close')
  1236. // resolve(true);
  1237. } else {
  1238. this.$message.error(res.message)
  1239. // resolve(false);
  1240. }
  1241. })
  1242. .finally(() => {
  1243. this.btndisabled = false
  1244. // resolve(false);
  1245. })
  1246. }
  1247. })
  1248. .catch(err => {
  1249. console.log(err, '校验失败')
  1250. // resolve(false);
  1251. })
  1252. // })
  1253. },
  1254. // 我的待办点击通过保存专用
  1255. handleSubmit2 (e) {
  1256. // return new Promise((resolve)=>{
  1257. // 通过函数获取数据
  1258. this.$refs.KFB.getData()
  1259. .then(res => {
  1260. // 处理手机端子表数据
  1261. if (this.isSJ) {
  1262. this.itemData(res)
  1263. }
  1264. // 清除为空的表单数据
  1265. _.keys(res).forEach(r => {
  1266. if (!res[r]) {
  1267. delete res[r]
  1268. }
  1269. })
  1270. // 获取数据成功
  1271. let formData = JSON.parse(JSON.stringify(res))
  1272. console.log(formData)
  1273. formData.id = this.data.id
  1274. formData.procDefId = this.processData.id
  1275. formData.procDeTitle = this.processData.name
  1276. // formData.jsonContent=JSON.stringify(this.jsonData)
  1277. if (!formData.tableName) formData.tableName = this.processData.businessTable
  1278. formData.filedNames = _.keys(res).join(',')
  1279. formData.filedNames = getFiledNames(formData) // 获取主表字段,排除子表标识
  1280. var url = this.url.addApply
  1281. if (!this.isNew) {
  1282. url = this.url.editForm
  1283. }
  1284. // 是否存在子表
  1285. let ischild = false
  1286. // 循环表单字段属性判断是否属性中包含数组对象
  1287. let i = 0 // 子表数量
  1288. _.keys(res)
  1289. .join(',')
  1290. .split(',')
  1291. .forEach(element => {
  1292. if (formData[element] instanceof Array) {
  1293. // 判断是否符合子表命名规则
  1294. if (element.indexOf('&') != -1) {
  1295. let tableChildNameList = element.split('&')
  1296. // 判断是否能拆分两个字符,子表标识和子表数据库名称
  1297. if (tableChildNameList.length == 2) {
  1298. i++
  1299. let childName = tableChildNameList[1] // 子表数据库名称
  1300. if (!formData.table_name_children) {
  1301. // 第一次拼接
  1302. formData.table_name_children = childName // 表名
  1303. } else {
  1304. // 后面的表明拼接用“,”隔开
  1305. formData.table_name_children = formData.table_name_children + ',' + childName // 表名
  1306. }
  1307. // 定义属性名和值
  1308. formData['childFiledNames' + i] = _.keys(formData[element][0]).join(',') // 子表字段名
  1309. formData['childList' + i] = JSON.stringify(formData[element]) // 子表数据
  1310. ischild = true
  1311. }
  1312. } else {
  1313. // 如果不是子表则是上传文件,则转字符串
  1314. formData[element] = JSON.stringify(formData[element])
  1315. }
  1316. }
  1317. // formData[element];
  1318. })
  1319. // 判断需不需要存子表
  1320. if (ischild) {
  1321. formData.filedNames = formData.filedNames + ',table_name_children'
  1322. }
  1323. console.log(formData)
  1324. // 子表数据
  1325. // 调用保存接口
  1326. this.btndisabled = true
  1327. this.todoManageOperationObject.formData = formData
  1328. this.todoManageOperationObject.url = url
  1329. // 获取是否部门负责人
  1330. formData.filedNames = formData.filedNames + ',is_leaders'
  1331. // formData.is_leaders = this.$store.getters.userInfo.identity
  1332. formData.is_leaders = this.$store.getters.userInfo.isPossess
  1333. // 清除子表规则的属性
  1334. _.keys(formData).forEach(r => {
  1335. if (r.indexOf('child&') != -1) {
  1336. delete formData[r]
  1337. }
  1338. })
  1339. // 如果手机端子表得则需要修改json
  1340. // var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
  1341. var jsonPamats = JSON.parse(JSON.stringify(this.jsonDataSave))
  1342. if (!this.isSJ && this.isNew) {
  1343. jsonPamats = null
  1344. }
  1345. this.todoManageOperationObject.jsonData = jsonPamats
  1346. })
  1347. .catch(err => {
  1348. console.log(err, '校验失败')
  1349. // resolve(false);
  1350. })
  1351. // })
  1352. },
  1353. close () {
  1354. this.$emit('close')
  1355. },
  1356. getData () {
  1357. // 通过函数获取数据
  1358. this.$refs.KFB.getData()
  1359. .then(res => {
  1360. // 获取数据成功
  1361. alert(JSON.stringify(res))
  1362. })
  1363. .catch(err => {
  1364. console.log(err, '校验失败')
  1365. })
  1366. },
  1367. // 刷新待办列表
  1368. refreshToDo () {
  1369. this.close()
  1370. this.$emit('getDataList')
  1371. },
  1372. itemData (res) {
  1373. var childName = '' // 子表规则名称
  1374. var itemIndex = 0
  1375. this.jsonData.list.forEach((element, index) => {
  1376. if (element.label.indexOf('child&') != -1) {
  1377. childName = element.label // 获取规则名
  1378. itemIndex = itemIndex + 1
  1379. }
  1380. })
  1381. var itemList = [] // 封装子表数据
  1382. for (var i = 1; i <= itemIndex; i++) {
  1383. var itemObject = {} // 子表对象
  1384. this.itemModelNameList.forEach(name => {
  1385. // 获取子表得值和封装对象
  1386. itemObject[name] = res[name + '@' + i]
  1387. delete res[name + '@' + i]
  1388. })
  1389. itemList.push(itemObject)
  1390. }
  1391. res[childName] = itemList // 完成子表数据封装
  1392. console.log(res)
  1393. },
  1394. deleteRow (idIndex) {
  1395. // 删除
  1396. this.jsonData.list.splice(idIndex, 1)
  1397. // 删除掉得json之后 重新处理model 和value
  1398. let childIndex = 0
  1399. this.jsonData.list.forEach((element, index) => {
  1400. if (element.label.indexOf('child&') != -1) {
  1401. childIndex = childIndex + 1
  1402. // 只有当前删除的对象json的后面对象json才进行修改
  1403. if (index >= idIndex) {
  1404. // 修改删除按钮的index
  1405. element.columns[0].list[1].options.defaultValue =
  1406. '<a href="javascript:void(0);" \n onclick="deleteRow(' + childIndex + ')">删除</a>'
  1407. // 修改model
  1408. updateModel(element, childIndex)
  1409. // 需要调整的子表值
  1410. var updateModelObject = {}
  1411. // 修改value
  1412. this.$refs.KFB.getData().then(res => {
  1413. // 根据原始字段名拼接带规则的
  1414. this.itemModelNameList.forEach(modelName => {
  1415. updateModelObject[modelName + '@' + childIndex] = res[modelName + '@' + (childIndex + 1)]
  1416. })
  1417. this.$refs.KFB.setData(updateModelObject)
  1418. })
  1419. }
  1420. }
  1421. })
  1422. console.log(JSON.stringify(this.jsonData.list))
  1423. },
  1424. add () {
  1425. let childLable = '' // 子表json标题
  1426. let childValue = {} // 新增子表json
  1427. let isReturn = false
  1428. let childIndex = 0
  1429. var itemList = []
  1430. this.jsonData.list.forEach((element, index) => {
  1431. if (element.label.indexOf('child&') != -1) {
  1432. childValue = JSON.parse(JSON.stringify(element))
  1433. childLable = element.label
  1434. // 处理删除按钮
  1435. childIndex = childIndex + 1
  1436. // element.columns[0].list[1].options.dynamicFun = 'delete' + childIndex
  1437. console.log(element.columns[0].list[1].options)
  1438. element.columns[0].list[1].options.defaultValue =
  1439. '<a href="javascript:void(0);" \n onclick="deleteRow(' + childIndex + ')">删除</a>'
  1440. updateModel(childValue, childIndex)
  1441. }
  1442. if (!isReturn && childLable != '' && element.label != childLable) {
  1443. isReturn = true
  1444. // 处理删除按钮
  1445. childIndex = childIndex + 1
  1446. // childValue.columns[0].list[1].options.dynamicFun = 'delete' + childIndex
  1447. childValue.columns[0].list[1].options.defaultValue =
  1448. '<a href="javascript:void(0);" \n onclick="deleteRow(' + childIndex + ')">删除</a>'
  1449. updateModel(childValue, childIndex)
  1450. // this.jsonData.list.splice(index, 0, childValue)
  1451. itemList.push(childValue)
  1452. }
  1453. itemList.push(element)
  1454. })
  1455. this.jsonData.list = itemList
  1456. console.log(JSON.stringify(this.jsonData.list))
  1457. },
  1458. // 把整个子表json的model进行规则修改
  1459. async listUpdateModel () {
  1460. let modelIndex = 0 // 子表model自增
  1461. // 循环整个json的表单
  1462. this.jsonData.list.forEach((element, index) => {
  1463. // 找到为子表的json
  1464. if (element.label.indexOf('child&') != -1) {
  1465. this.isSJ = true
  1466. // 获取子表原始得model字段名
  1467. if (modelIndex == 0) {
  1468. var i = 1
  1469. var itemString = JSON.stringify(element)
  1470. var itemModelNameList = [] // 储存子表字段名
  1471. for (var i = 1; i !== -1;) {
  1472. // 动态字符位置
  1473. i = itemString.indexOf('"model"', i)
  1474. if (i !== -1) {
  1475. // 从指定字符的周后一个字符后开始找(")
  1476. var ihStart = itemString.indexOf('"', i + 7)
  1477. // 再从 (") 后面位置还是找下一个 (")
  1478. var ihEnd = itemString.indexOf('"', ihStart + 1)
  1479. // 获取引号之间的字符
  1480. var model = itemString.substring(ihStart + 1, ihEnd)
  1481. // 如果动态表示不为空则获取
  1482. if (model != '') {
  1483. if (model.indexOf('@') != -1) {
  1484. model = model.substring(0, model.length - 2)
  1485. }
  1486. itemModelNameList.push(model)
  1487. }
  1488. i = ihEnd + 1
  1489. }
  1490. }
  1491. this.itemModelNameList = itemModelNameList
  1492. }
  1493. modelIndex = modelIndex + 1
  1494. // 修改model
  1495. updateModel(element, modelIndex)
  1496. }
  1497. })
  1498. },
  1499. //计算时间差
  1500. timeDifference(start, end,state){
  1501. if(getProjctName() =='技能博物馆'){
  1502. var startDayArr = start.split(' '),
  1503. startDay = startDayArr[0]+' '+'16:00'
  1504. // 计算出请假第一天距离下班多久
  1505. var s1 = new Date(start.replace(/-/g, '/')),
  1506. s2 = new Date(startDay.replace(/-/g, '/')),
  1507. ms = Math.abs(s1.getTime() - s2.getTime()),
  1508. mins= (ms / 1000 / 60 / 60);
  1509. // ___________
  1510. var endDayArr = end.split(' '),
  1511. endDay = endDayArr[0]+' '+'9:00'
  1512. // 计算出请假最后一天距离上班多久
  1513. var s11 = new Date(end.replace(/-/g, '/')),
  1514. s22 = new Date(endDay.replace(/-/g, '/')),
  1515. ms2 = Math.abs(s11.getTime() - s22.getTime()),
  1516. mins2= (ms2 / 1000 / 60 / 60);
  1517. // ————————
  1518. var startDay = new Date(start),
  1519. endDay = new Date(end),
  1520. startDateTime=new Date(startDay.setDate(startDay.getDate()+1));
  1521. startDateTime =(moment(startDateTime).format('YYYY-MM-DD HH:mm')).split(' ')
  1522. var EndDateTime=new Date(endDay.setDate(endDay.getDate()-1));
  1523. EndDateTime =(moment(EndDateTime).format('YYYY-MM-DD HH:mm')).split(' ')
  1524. var myDate_1 = Date.parse(EndDateTime[0]),
  1525. myDate_2 = Date.parse(startDateTime[0])
  1526. //计算除去第一天和最后一天后相差多少天
  1527. var diffDate = Math.abs(myDate_1 - myDate_2), // 取相差毫秒数的绝对值
  1528. totalDays = Math.floor(diffDate / (1000 * 3600 * 24))+1 // 向下取整
  1529. if(startDateTime>EndDateTime){
  1530. totalDays = 0
  1531. }
  1532. var dayTime = (totalDays+(mins+mins2)/8).toFixed(1)
  1533. return dayTime
  1534. }else{
  1535. // if(start>end){
  1536. // this.$message.error('起始时间不可大于结束时间');
  1537. // }else{
  1538. let beginTime = (new Date(start).getTime()) / 1000;
  1539. let endTime = (new Date(end).getTime()) / 1000;
  1540. //计算天数
  1541. var timediff = endTime - beginTime;
  1542. var days = parseInt(timediff / 86400); //60*60*24
  1543. //计算小时数
  1544. var remain = timediff % 86400 ;
  1545. var hours = parseInt(remain / 3600);
  1546. //计算分钟数
  1547. var remain = remain % 3600;
  1548. var mins = parseInt(remain / 60);
  1549. var res = days + '天' + hours + '小时' + mins + '分';
  1550. if(state == 'min'){
  1551. return days*24*60+hours*60+mins
  1552. }else if(state == 'hour'){
  1553. return days*24+hours+mins/60
  1554. }else if(state == 'day'){
  1555. if(start.split(' ').length==1 && end.split(' ').length == 1){
  1556. return days+1+hours/24+mins/60/24
  1557. }else{
  1558. return days+hours/24+mins/60/24
  1559. }
  1560. }else if(state == 'day/hour/min'){
  1561. return days+'天'+hours+'小时'+mins+'分'
  1562. }else if(state == 'hour/min'){
  1563. return (days*24+hours)+'小时'+mins+'分'
  1564. }
  1565. }
  1566. }
  1567. }
  1568. // }
  1569. }
  1570. // 获取主表字段,排除子表标识
  1571. function getFiledNames (formData) {
  1572. let filedNames = ''
  1573. let list = formData.filedNames.split(',') // 获取表单属性名集合
  1574. list.forEach(element => {
  1575. if (element.indexOf('&') == -1) {
  1576. // 查询是否有这个字段
  1577. if (filedNames == '') {
  1578. // 第一次则直接等于
  1579. filedNames = element
  1580. } else {
  1581. // 后面用逗号隔开
  1582. filedNames = filedNames + ',' + element
  1583. }
  1584. }
  1585. })
  1586. return filedNames
  1587. }
  1588. // 根据开始时间 结束时间计算天数
  1589. function startEndFun (start, end) {
  1590. let startTime = new Date(start)
  1591. let endTime = new Date(end)
  1592. if (startTime >= endTime) {
  1593. return 0
  1594. }
  1595. // 1,分钟取整
  1596. startTime = carryTime(startTime)
  1597. endTime = carryTime(endTime)
  1598. // 2,计算总天数
  1599. var totalTime = 0 // 工时,天数
  1600. if (startTime.getDay() == 6 || startTime.getDay() == 0) {
  1601. totalTime = endTime.getDate() - startTime.getDate()
  1602. } else {
  1603. totalTime = Math.floor((endTime - startTime) / (3600 * 1000) / 24)
  1604. }
  1605. // 3,拿初始值赋值给一个临时变量
  1606. var tempStartTime = new Date()
  1607. tempStartTime.setTime(startTime.getTime())
  1608. // 4,计算出总天数
  1609. while (tempStartTime.getDate() < endTime.getDate()) {
  1610. if (tempStartTime.getDay() == 6 || tempStartTime.getDay() == 0) {
  1611. // 周六或者周日减去
  1612. totalTime--
  1613. }
  1614. tempStartTime.setDate(tempStartTime.getDate() + 1)
  1615. }
  1616. // 5,计算出总小时数
  1617. var temp = 0 // 工时,小时
  1618. do {
  1619. if (startTime.getDay() == 6 || startTime.getDay() == 0) {
  1620. // 周六周日
  1621. startTime.setDate(startTime.getDate() + 1)
  1622. //* ********周六周日直接跳过,初始化为早晨9点
  1623. startTime.setHours(9)
  1624. startTime.setMinutes(0)
  1625. continue
  1626. }
  1627. if (endTime.getDay() == 6 || endTime.getDay() == 0) {
  1628. // 周六周日
  1629. endTime.setDate(endTime.getDate() + 1)
  1630. //* ********周六周日直接跳过,初始化为早晨9点
  1631. endTime.setHours(9)
  1632. endTime.setMinutes(0)
  1633. continue
  1634. }
  1635. let tempMinutes = startTime.getHours() * 60 + startTime.getMinutes()
  1636. // 上午9点到12点半,算工时
  1637. if (tempMinutes >= 9 * 60 && tempMinutes < 12 * 60) {
  1638. temp += 0.05
  1639. }
  1640. // 上午14点到18点半,算工时
  1641. if (tempMinutes >= 13 * 60 && tempMinutes < 18 * 60) {
  1642. temp += 0.05
  1643. }
  1644. startTime.setTime(startTime.getTime() + 0.5 * 3600 * 1000) // 每次增加半个小时
  1645. } while (startTime.getHours() * 60 + startTime.getMinutes() != endTime.getHours() * 60 + endTime.getMinutes())
  1646. {
  1647. totalTime += Math.floor(temp / 0.8)
  1648. totalTime += temp % 0.8
  1649. totalTime = Math.round(totalTime * 100) / 100
  1650. }
  1651. var days = Math.floor(totalTime)
  1652. var hours = Math.round((totalTime - days) * 100) / 10
  1653. console.log(days + '天', hours + '小时')
  1654. return days * 8 + hours
  1655. // if (start && end) {
  1656. // let startTime = new Date(start) // 开始时间
  1657. // let endTime = new Date(end) // 结束时间
  1658. // let usedTime = endTime - startTime // 相差的毫秒数
  1659. // let days = (usedTime / 1000 / 60 / 60).toFixed(2) // 计算出天数
  1660. // return days
  1661. // } else {
  1662. // return null
  1663. // }
  1664. }
  1665. // 格式化时间
  1666. function formatDate (date, fmt) {
  1667. if (/(y+)/.test(fmt)) {
  1668. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
  1669. }
  1670. let o = {
  1671. 'M+': date.getMonth() + 1,
  1672. 'd+': date.getDate(),
  1673. 'h+': date.getHours(),
  1674. 'm+': date.getMinutes(),
  1675. 's+': date.getSeconds()
  1676. }
  1677. for (let k in o) {
  1678. if (new RegExp(`(${k})`).test(fmt)) {
  1679. let str = o[k] + ''
  1680. fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : padLeftZero(str))
  1681. }
  1682. }
  1683. return fmt
  1684. }
  1685. function padLeftZero (str) {
  1686. return ('00' + str).substr(str.length)
  1687. }
  1688. /*
  1689. * 0-15分不算工时
  1690. * 15-45算半个小时
  1691. * 45-60算一个小时
  1692. * */
  1693. function carryTime (date) {
  1694. if (date.getMinutes() > 0 && date.getMinutes() < 15) {
  1695. date.setMinutes(0)
  1696. }
  1697. if (date.getMinutes() >= 15 && date.getMinutes() < 30) {
  1698. date.setMinutes(30)
  1699. }
  1700. if (date.getMinutes() > 30 && date.getMinutes() < 45) {
  1701. date.setMinutes(30)
  1702. }
  1703. if (date.getMinutes() >= 45) {
  1704. date.setHours(date.getHours() + 1)
  1705. date.setMinutes(0)
  1706. }
  1707. return date
  1708. }
  1709. // function
  1710. /**
  1711. * 修改model绑定值
  1712. */
  1713. function updateModel (object, childIndex) {
  1714. let keyString = _.keys(object).join(',')
  1715. if (keyString.indexOf('model') != -1) {
  1716. // 如果没有修改过则直接修改
  1717. if (object['model'].indexOf('@') == -1) {
  1718. object['model'] = object['model'] + '@' + childIndex
  1719. } else {
  1720. // 修改过则截取修改前的再进行修改
  1721. var m = object['model'].substring(0, object['model'].length - 2)
  1722. object['model'] = m + '@' + childIndex
  1723. }
  1724. }
  1725. // 递归
  1726. _.keys(object)
  1727. .join(',')
  1728. .split(',')
  1729. .forEach(l => {
  1730. if (object[l] instanceof Array) {
  1731. object[l].forEach(element => {
  1732. updateModel(element, childIndex)
  1733. })
  1734. }
  1735. })
  1736. }
  1737. </script>
  1738. <style lang="less" scoped>
  1739. @media print {
  1740. @page {
  1741. /* 横向 */
  1742. size: landscape;
  1743. /* 去除浏览器默认页眉页脚 */
  1744. margin: 0;
  1745. }
  1746. * {
  1747. -webkit-print-color-adjust: exact !important; /* Chrome, Safari */
  1748. color-adjust: exact !important; /*Firefox*/
  1749. }
  1750. .noprint {
  1751. display: none;
  1752. }
  1753. // /deep/.ant-input{
  1754. // border: none !important;
  1755. // }
  1756. // /deep/ .ant-modal-header{
  1757. // display: none !important;
  1758. // }
  1759. // /deep/ .ant-modal-content{
  1760. // box-shadow:none !important
  1761. // }
  1762. /deep/ * {
  1763. color: #000000!important;
  1764. -webkit-tap-highlight-color: #000000!important;
  1765. }
  1766. /*update_end author:scott date:20191203 for:打印机打印的字体模糊问题 */
  1767. /deep/ .abcdefg .ant-card-body{
  1768. margin-left: 0%;
  1769. margin-right: 0%;
  1770. margin-bottom: 1%;
  1771. border:0px solid black;
  1772. min-width: 800px;
  1773. color:#000000!important;
  1774. }
  1775. /deep/ .explain{
  1776. text-align: left;
  1777. margin-left: 50px;
  1778. color:#000000!important;
  1779. }
  1780. /deep/ .explain .ant-input,.sign .ant-input{
  1781. font-weight:bolder;
  1782. text-align:center;
  1783. border-left-width:0px!important;
  1784. border-top-width:0px!important;
  1785. border-right-width:0px!important;
  1786. }
  1787. /deep/ .explain div{
  1788. margin-bottom: 10px;
  1789. }
  1790. /* you can make up upload button and sample style by using stylesheets */
  1791. /deep/ .ant-upload-select-picture-card i {
  1792. font-size: 32px;
  1793. color: #999;
  1794. }
  1795. /deep/ .ant-upload-select-picture-card .ant-upload-text {
  1796. margin-top: 8px;
  1797. color: #666;
  1798. }
  1799. }
  1800. /deep/ .anticon-question-circle-o {
  1801. display: none !important;
  1802. }
  1803. /deep/ textarea#presentation_condition {
  1804. height: 290px;
  1805. }
  1806. /deep/ .active .ant-select-selection {
  1807. border: 1px solid red;
  1808. }
  1809. </style>