123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977 |
- <template>
- <div class="form-main" id="form-main" >
- <div v-if="printTitle" class="no-print" style="text-align: right">
-
- <a-button v-if="printMould" :href="printMouldUrl" target="_blank"
- ghost type="primary">模板打印</a-button>
- <!-- <a-button v-if="printShow" v-print="'#printContent'" ghost type="primary">打印</a-button> -->
- </div>
- <a-card :body-style="{ padding: '15px 32px' }" :bordered="false" id="printContent" :class="{'abcdefg':true}" >
- <section ref="print" id="printContent" class="abcdefg">
- <!-- <a-form @submit="handleSubmit" :form="form">
- <a-form-item
- label="标题"
- :labelCol="{lg: {span: 7}, sm: {span: 7}}"
- :wrapperCol="{lg: {span: 10}, sm: {span: 17} }">
- <a-input :disabled="disabled"
- v-decorator="[
- 'name',
- {rules: [{ required: true, message: '请输入标题' }]}
- ]"
- name="name"
- placeholder="给目标起个名字" />
- </a-form-item>
- <a-form-item v-if="!disabled"
- :wrapperCol="{ span: 24 }"
- style="text-align: center"
- >
- <a-button htmlType="submit" type="primary" :disabled="disabled||btndisabled" @click="handleSubmit">保存</a-button>
- <a-button style="margin-left: 8px" :disabled="disabled" @click="close">取消</a-button>
- </a-form-item>
- </a-form>-->
- <k-form-build
- :value="jsonData"
- @change="handleChange"
- :dynamicData="dynamicData"
- ref="KFB"
- @submit="handleSubmit"
- />
- <div v-if="printTitleImg" style="text-align: right;margin-right: 13%">
- <!-- <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"/> -->
- <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"/>
- </div>
- </section>
- <div style="text-align:center">
- <a-button
- htmlType="submit"
- type="primary"
- :disabled="disabled || btndisabled"
- @click="handleSubmit"
- class="noprint"
- >保存</a-button>
- <todoManageOperation
- v-if="processData.operationType && processData.operationType == '1'"
- :processData="processData"
- :todoManageOperationObject="todoManageOperationObject"
- :disabled="disabled"
- :btndisabled="btndisabled"
- @refreshToDo="refreshToDo"
- @handleSubmit2="handleSubmit2"
- ></todoManageOperation>
- <a-button style="margin-left: 8px;" :disabled="disabled || disabled2" @click="close" class="noprint">取消</a-button>
- <!-- <a-button type="primary" v-if="printDisable" @click="changedd" class="noprint" style="margin-left:10px">打印</a-button> -->
- </div>
- </a-card>
- <personnel-files-modal ref="personnelFilesModal" @close="closeP"></personnel-files-modal>
- <fixed-zy-modal ref="FixedZyModal" @close="closeP"></fixed-zy-modal>
- <car-sq-modal ref="CarSqModal" @close="closeP"></car-sq-modal>
- <material-sl-modal ref="MaterialSlModal" @close="closeP"></material-sl-modal>
- </div>
- </template>
- <script>
- import pick from 'lodash.pick'
- import todoManageOperation from '../operation/todoManageOperation'
- import PersonnelFilesModal from './personnelFilesModal'
- import CarSqModal from './carSqModal'
- import MaterialSlModal from './materialSlModal'
- import FixedZyModal from './fixedZyModal'
- import { postAction, postFormDataAction} from '@/api/manage'
- import {annualLeave} from '@api/oa/cd-personnel-files'
- import moment from 'moment'
- import {getProjctName} from '../../../../url.config'
- import ACol from "ant-design-vue/es/grid/Col";
- import ARow from "ant-design-vue/es/grid/Row";
- import ATextarea from 'ant-design-vue/es/input/TextArea'
- export default {
- name: 'DemoForm',
- props: {
- reBizCode:{
- type: String,
- default: ''
- },
- /* 全局禁用,可表示查看 */
- disabled: {
- type: Boolean,
- default: false,
- required: false
- },
- /* 流程数据 */
- processData: {
- type: Object,
- default: () => {
- return {}
- },
- required: false
- },
- /* 是否新增 */
- isNew: { type: Boolean, default: false, required: false }
- },
- components: {
- ATextarea,
- ARow,
- ACol,
- todoManageOperation,
- moment,
- PersonnelFilesModal,
- FixedZyModal,
- CarSqModal,
- MaterialSlModal,
- },
- data () {
- return {
- printMould:false,
- printShow:true,
- printMouldUrl:'',
- printTitle:false,
- printTitleImg:false,
- isSJ: false,
- todoManageOperationObject: {
- isSave: false,
- formData: {},
- jsonData: {}
- },
- leave:0,//剩余年假
- disabled2: false, // 用来取决于表单时不同流程节点填写不同表单信息使用
- jsonData: {}, // 前台任意改变的json
- jsonDataSave: {}, // 保存到数据库的json
- url: {
- getForm: '/actBusiness/getForm',
- addApply: '/actBusiness/add',
- editForm: '/actBusiness/editForm',
- leaveType: '/sys/dict/getDictItems'
- },
- description: '流程表单demo,按例开发表单。需在 activitiMixin.js 中加入写好的表单',
- // form
- form: this.$form.createForm(this),
- /* 表单回显数据 */
- data: {},
- btndisabled: false,
- ceshi_file: null,
- fArr:[],//保存含有help的单个表单信息
- cvarr:[],//保存表单所有的label和key(用来寻找改变字段对应的key)
- bv:[],//保存所有含有help的表单信息
- dynamicData: {
- jsonData: {},
- typeData: [], // 请假类型下拉数据
- reimbursementTypeList: [], // 报销类型下拉数据
- invoiceTypeList: [], // 发票类型下拉数据
- add: this.add,
- gv:this.funName,
- department:[],//技能博物管下拉框信息
- personListJn:[],//技能博物馆人员信息下拉框
- fundApproval:[],//技能博物馆项目信息
- conferenceRoom:[],//技能博物馆会议室信息
- unit:[ //技能博物馆-物料库存-单位
- {label:'个',value:'个'},
- {label:'支',value:'支'},
- {label:'套',value:'套'},
- {label:'台',value:'台'},
- ]
- },
- postInfo: {},//职位信息
- deptInfo: {},//部门信息
- itemModelNameList: [], // 子表字段名
- buttonArr:[],
- printDisable:false//打印按钮
- }
- },
- watch: {
- // 'dynamicData.jsonData'(){
- // console.log("发生改变了")
- // },
- dynamicData: {
- handler (newName, oldName) {
- // console.log('obj.a changed')
- // console.log(newName)
- // console.log(oldName)
- newName.handle = this.funName1
- newName.fixed_zy = this.fixedZy
- newName.fixed_gh =this.fixedGh
- newName.fixed_db=this.fixedDb
- newName.fixed_bf=this.fixedBf
- newName.car_sq = this.carSq
- newName.material_sl = this.materialSl
- },
- immediate: true,
- deep: true
- }
- },
- created () {
- // debugger
- // console.log("==============="+this.processData);
- // console.log("==============="+this.processData.status);
- // console.log("==============="+this.processData.title);
- // console.log("==============="+this.processData.businessTable);
- // console.log("==============="+getProjctName());
- window.deleteRow = this.deleteRow
- // console.log('流程数据', this.processData)
- // 加载一些下拉选择数据等
- // this.getDataList()
- let businessTable = ''
- // 如果没有值则在另一个属性上有值
- if (!this.processData.businessTable) {
- this.processData.businessTable = this.processData.tableName
- }
- // debugger
- this.getAction('/tbTableInfo/query', {
- businessTable: this.processData.businessTable,
- taskNodeId: this.processData.key,
- tableId: this.processData.tableId,
- type: '1'
- }).then(res => {
- var jsonString = JSON.stringify(res.result.jsonContent)
- var index = 1
- var dynamicKeyValueList = []
- for (var index = 1; index !== -1;) {
- // 动态字符位置
- index = jsonString.indexOf('"dynamicKey"', index)
- if (index !== -1) {
- // 从指定字符的周后一个字符后开始找(")
- var ihStart = jsonString.indexOf('"', index + 12)
- // 再从 (") 后面位置还是找下一个 (")
- var ihEnd = jsonString.indexOf('"', ihStart + 1)
- // 获取引号之间的字符
- var dynamicKeyValue = jsonString.substring(ihStart + 1, ihEnd)
- // 如果动态表示不为空则获取
- if (dynamicKeyValue != '') {
- dynamicKeyValueList.push(dynamicKeyValue)
- }
- index = ihEnd + 1
- }
- }
- let that = this;
- if (dynamicKeyValueList.length > 0) {
- // 获取数据字典数据源
- postAction('/sys/dict/getDictItems/getDictList', dynamicKeyValueList).then(dictData => {
- if (dictData.success) {
- this.dynamicData = dictData.result.dicList
- if(getProjctName() =='技能博物馆'){
- //技能博物馆部门信息
- this.getAction('/sys/sysDepart/queryMyDeptList').then(res => {
- if (res.success) {
- var aa=[]
- res.result.map(item=>{
- aa.push({value:item.departName,label:item.departName})
- })
- this.dynamicData.department = aa
- } else {
- this.$message.error(res.message)
- }
- })
- //技能博物馆人员信息
- this.getAction('/sys/user/list', { pageSize: -1}).then(res => {
- if (res.success) {
- var aa = []
- res.result.records.map(item =>{
- aa.push(
- {value:item.realname,
- label:item.realname,
- workNo:item.workNo,
- post:item.post,
- nInductionTime:item.nInductionTimenInductionTime,
- phone:item.phone,
- telephone:item.telephone,
- departIds_dictText:item.orgCode,
- departIds:item.departIds
- })
- })
- this.dynamicData.personListJn = aa
- //技能博物馆 --- 全馆值班 此时无法触碰到handleChange方法 手动触发
- // if(this.processData.businessTable == 'bwg_house_duty'){
- // this.handleChange()
- // }
- } else {
- this.$message.error(res.message)
- }
- })
- //技能博物馆项目信息
- this.getAction('/oa/activiti/getSelectionList',{tableName:'bwg_project_start'}).then(res => {
- if (res.success) {
- var aa=[]
- res.result.map(item=>{
- aa.push(
- {value:item.project_name,
- label:item.project_name,
- startDate:item.start_date,
- endDate:item.end_date,
- projectReasons:item.project_reasons,
- budgetInformation:item.budget_information
- })
- })
- this.dynamicData.fundApproval = aa
- } else {
- this.$message.error(res.message)
- }
- })
- //技能博物馆会议室信息
- this.getAction('/oa/meetingRoom/all').then(res => {
- if (res.success) {
- var aa=[]
- res.result.map(item=>{
- aa.push({value:item.name,label:item.name})
- })
- this.dynamicData.conferenceRoom = aa
- } else {
- this.$message.error(res.message)
- }
- })
- }
- // 获取用户下拉数据
- this.getAction('/sys/user/list2', { pageSize: 20000 }).then(userData => {
- if (res.success) {
-
- if(userData.data != null && userData.data.supplierList != null){
- // userData.data.supplierList.forEach(user => {
- // console.log("userDatacode",user.code);
- // console.log("userDataname",user.name);
- // })
- this.dynamicData.supplierList = userData.data.supplierList
- this.dynamicData.customerList = userData.data.customerList
- this.dynamicData.userNameList = userData.data.userNameList
- this.dynamicData.userYWList = userData.data.userYWList
- this.dynamicData.userQCList = userData.data.userQCList
- }
-
- userData.result.records.forEach(user => {
- user.label = user.realname
- user.value = user.username
- that.postInfo[user.username] = user.post
- that.deptInfo[user.username] = user.deptName
- })
- // 存到动态数据源中
- this.dynamicData.userList = userData.result.records
- this.dynamicData.add = this.add // 新增按钮
-
- // 获取json
- this.jsonData = res.result.jsonContent
- // this.jsonData.list[2].columns[0].list[0].help = "date_1663752082983,date_1663753163575,min"
- this.cvarr = []
- this.cvarr = []
- this.fArr =[]
- //遍历help
- this.forHelp(this.jsonData)
- this.jsonDataSave = JSON.parse(JSON.stringify(res.result.jsonContent))
- // 获取申请人信息
- this.getApplicant()
- // 如果是手机端子表初始化子表model
- this.listUpdateModel()
- if (!this.isNew) {
- this.init()
- }
- } else {
- this.$message.error(userData.message)
- }
- })
- } else {
- this.$message.error(dictData.message)
- }
- })
- } else {
- // 获取json
- this.jsonData = res.result.jsonContent
- // this.jsonData.list[0].trs[5].tds[2].list[0].help = 'input_1662521241170,input_1662521240862,-'
- // this.jsonData.list[0].trs[3].tds[2].list[0].help = 'today'
- this.cvarr = []
- this.fArr =[]
- //遍历help(计算)
- this.forHelp(this.jsonData)
- // 获取申请人信息
- this.getApplicant()
- // 如果是手机端子表初始化子表model
- this.listUpdateModel()
- // window.jsonData=this.jsonData;
- if (!this.isNew) {
- this.init()
- }
- }
-
- // 后台检测到流程节点有关联表单且前台处于我的待办界面打开表单详情
- if (res.result.isSave && this.processData.isSuspended != undefined) {
- this.disabled = false
- this.btndisabled = false
- }
- })
- },
- methods: {
- fixedZy(){
- this.$refs.FixedZyModal.fixedZyModVis = true
- this.$refs.FixedZyModal.personLists('闲置')
- this.$refs.FixedZyModal.sat = '转移'
- },
- fixedGh(){
- this.$refs.FixedZyModal.fixedZyModVis = true
- this.$refs.FixedZyModal.personLists('领用,转移,调拨')
- this.$refs.FixedZyModal.sat = '归还'
- },
- fixedDb(){
- this.$refs.FixedZyModal.fixedZyModVis = true
- this.$refs.FixedZyModal.personLists('闲置')
- this.$refs.FixedZyModal.sat = '调拨'
- },
- fixedBf(){
- this.$refs.FixedZyModal.fixedZyModVis = true
- this.$refs.FixedZyModal.personLists('调拨,转移,领用,闲置')
- this.$refs.FixedZyModal.sat = '报废'
- },
- carSq(){
- this.$refs.CarSqModal.carSqModVis = true
- this.$refs.CarSqModal.personLists()
- },
- materialSl(){
- this.$refs.MaterialSlModal.materialSlModVis = true
- this.$refs.MaterialSlModal.personLists()
- },
- //获取部门信息
- getDepartment(){
- this.$refs.DepartmentModal.departmentModVis = true
- this.$refs.DepartmentModal.personLists()
- },
- closeP(value){
- var that = this
- this.cvarr.map(item=>{
- for(let key in value){
- if(item.model == key){
- setTimeout(function(){
- that.$refs.KFB.setData({[key]:value[key]})
- },0)
- }
- }
-
- })
-
-
- },
- funName1(){
- this.$refs.personnelFilesModal.declareElementsModVis = true
- this.$refs.personnelFilesModal.personLists()
- },
- // 根据字典名字获取数据源
- getDataListByName (name) {
- this.getAction(this.url.leaveType + '/' + name).then(res => {
- if (res.success) {
- this.dynamicData[name] = res.result
- console.log(111)
- } else {
- this.$message.error(res.message)
- }
- })
- },
- // 获取获取下拉数据等
- getDataList () {
- // 获取请假类型下拉数据
- this.getAction(this.url.leaveType + '/leave_type').then(res => {
- if (res.success) {
- this.dynamicData.typeData = res.result
- } else {
- this.$message.error(res.message)
- }
- })
- // 获取报销类型下拉数据
- this.getAction(this.url.leaveType + '/reimbursement_type').then(res => {
- if (res.success) {
- this.dynamicData.reimbursementTypeList = res.result
- } else {
- this.$message.error(res.message)
- }
- })
- // 获取发票类型下拉数据
- this.getAction(this.url.leaveType + '/invoice_type').then(res => {
- if (res.success) {
- this.dynamicData.invoiceTypeList = res.result
- } else {
- this.$message.error(res.message)
- }
- })
- },
- /* 回显数据 */
- init () {
- this.btndisabled = true
- var r = this.processData
- this.getAction(this.url.getForm, {
- tableId: r.tableId,
- tableName: r.tableName
- }).then(res => {
- // 第一次调接口根据子表数据渲染子表前台效果
- // 只有手机端才执行
- if (this.isSJ) {
- _.keys(res.result).forEach((e, i) => {
- if (e.indexOf('child&') != -1) {
- if (i > 0) {
- this.add()
- }
- }
- })
- }
- this.getAction(this.url.getForm, {
- tableId: r.tableId,
- tableName: r.tableName
- }).then(res => {
- if (res.success) {
- let formData = res.result
- formData.tableName = r.tableName
- // console.log("taboe",formData);
- this.data = formData
- // 如果表单是手机端的子表则
- if (this.isSJ) {
- var formModelList = _.keys(this.data)
- .join(',')
- .split(',')
- var itemList = []
- formModelList.forEach(element => {
- if (element.indexOf('child&') != -1) {
- itemList = JSON.parse(JSON.stringify(this.data[element]))
- delete this.data[element]
- }
- })
- // 子表字段名
- // 子表数据model和值组装
- itemList.forEach((item, index) => {
- this.itemModelNameList.forEach(itemModelName => {
- this.data[itemModelName + '@' + (index + 1)] = item[itemModelName]
- })
- })
- }
- // 赋值
- this.$refs.KFB.setData(this.data)
- this.btndisabled = false
- // debugger
- // console.log(this.processData);
- if(this.processData.result == 2){
- this.printTitle = true;
-
- if(this.processData.businessTable == 'meeting_summary'){ //会议纪要
- let leadership_pass = this.$refs.KFB.form.getFieldValue('leadership_pass');
- if(leadership_pass == 2){
- this.printTitleImg = false;
- }else{
- this.printTitleImg = true;
- }
- }else if(this.processData.businessTable == 'incident_ticket'){ //质量事故单
- this.printTitleImg = true;
- this.printShow = false;
- }else if(this.processData.businessTable == 'separation_application' || //离职
- this.processData.businessTable == 'personnel_recruitment_apply' || //人员需求
- this.processData.businessTable == 'regular_employee_apply' || //转正申请
- this.processData.businessTable == 'incident_ticket' || //质量事故单
- this.processData.businessTable == 'welfare'){ //福利发放单
-
- this.printTitleImg = true;
- }else if(this.processData.businessTable == 'expense_account'){//报销单
-
- let expense_type = this.$refs.KFB.form.getFieldValue('expense_type');
- if(expense_type == '业务需求报销' || expense_type == '日常用品报销'){ //业务需求报销/日常用品报销需要,其他不需要
- this.printTitleImg = true;
- }else{
- this.printTitleImg = false;
- }
-
- }else if(this.processData.businessTable == 'supplieses_apply_a'){//物质申请单
- var sonTable=[]
- // 获取子表数据
- _.keys(formData).forEach(r => {
- if (r.indexOf('child&') != -1) {
- sonTable=formData[r]
- }
- })
- if(sonTable[0].procurement_type !== '公司采购'){ //公司采购,不显示签名
- this.printTitleImg = true;
- }else{
- this.printTitleImg = false;
- }
-
- }else{
- this.printTitleImg = false;
- }
- let that = this;
- let businessTable = this.processData.businessTable;
- if(this.printTitleImg){
- businessTable = businessTable+'_img'
- }
- this.getAction('/sys/dict/selectDictByJiMuPrint',{tableName:businessTable}).then(res => {
- if(res !=null && res !=''){
- that.printMouldUrl = res.value+'?'+res.text+'='+that.processData.tableId ;
- this.printMould = true;
- }else{
- this.printMould = false;
- }
- })
-
- }else{
- this.printTitleImg = false;
- this.printTitle = false;
- }
-
- } else {
- this.$message.error(res.message)
- }
- })
-
-
- })
-
- },
- //遍历help
- forHelp(obj){
- for(var a in obj){
- if (typeof(obj[a]) == "object"){
- if(obj[a].help !=='' && obj[a].help){
- //保存每一项的label和key
- this.cvarr.push({model:obj[a].model,key:obj[a].key,type:obj[a].type})
- obj[a].help = obj[a].help.split(',')
- //保存含有help的item中的label和help里的信息
- this.fArr=[
- {
- label:obj[a].model,
- value:'',
- },
- {
- label: obj[a].help[0],
- value:'',
- },
- {
- label: obj[a].help[1],
- value:'',
- },
- {
- label: obj[a].help[2],
- value:'',
- },
- ]
- //保存多各含有help的数据
- this.bv.push({bn:this.fArr})
- //默认当天时间
- this.defualtData(this.fArr)
- }else if(obj[a].help ==''){
- this.cvarr.push({model:obj[a].model,key:obj[a].key,type:obj[a].type})
- }else if(obj[a].type == 'button'){
- this.buttonArr.push(obj[a])
- this.buttonShow(obj[a])
- }
- this.forHelp(obj[a])
- }
- }
-
- },
- buttonShow(obj){
- if(obj.label == '打印'){
- this.printDisable = true
- }
- },
- //默认时间/默认当前账号
- defualtData(item){
- if(item[1].label =='today'){
- if(item[2].label){
- item[0].value =moment(new Date().toLocaleDateString()).format('YYYY-MM-DD')
- }else{
- item[0].value =moment(new Date().toLocaleDateString()).format('YYYY-MM-DD HH:mm')
- }
- var that = this
- setTimeout(function(){
- that.$refs.KFB.setData({[item[0].label]:item[0].value})
- },0)
-
- }else if(item[1].label =='deptName'){
- var that = this
- setTimeout(function(){
- that.$refs.KFB.setData({[item[0].label]:that.$store.getters.userInfo.deptName})
- },200)
-
- }else if(item[1].label =='user'){
- // this.$store.getters.userInfo
- var that = this
- setTimeout(function(){
- that.$refs.KFB.setData({[item[0].label]:that.$store.getters.userInfo.realname})
- // 森语-请假单-须根据当前用户带出剩余年假
- if(that.processData.businessTable =='employee_leave'){
- annualLeave({username:that.$store.getters.userInfo.username}).then(res => {
- if (res.success) {
- that.leave = res.result.nannualNowNum
- that.$refs.KFB.setData({leave_remaining: that.leave})
- }
-
- })
- }
- var jnDeparment = ''
- if(getProjctName() =='技能博物馆'){ //获取技能博物馆登录人对应的部门
- that.dynamicData.personListJn.map(item =>{
- if(item.label == that.$store.getters.nickname){
- jnDeparment = item.departIds_dictText
- }
- })
- }
- if(that.processData.businessTable == 'regular_employee_apply'){//员工转正申请
- that.$refs.KFB.setData({apply_department:that.deptInfo[that.$store.getters.userInfo.username]})
- // that.$refs.KFB.setData({job_title:that.postInfo[that.$store.getters.userInfo.username]})
- }
- if(that.processData.businessTable == 'seal_apply'){//用印申请单
- that.$refs.KFB.setData({apply_department:that.deptInfo[that.$store.getters.userInfo.username]})
- }
- if(that.processData.businessTable == 'separation_application'){//离职申请
- that.$refs.KFB.setData({job_title:that.postInfo[that.$store.getters.userInfo.username]})
- }
- if(that.processData.businessTable == 'bwg_house_duty'){ // 技能博物馆--全馆值班 --默认当前登陆人
- that.$refs.KFB.setData({referrer:that.$store.getters.nickname})
- that.dynamicData.personListJn.map(item =>{
- if(item.label == that.$store.getters.nickname){
- that.$refs.KFB.setData({department_id:item.departIds})
- that.$refs.KFB.setData({department_name:item.departIds_dictText})
- that.$refs.KFB.setData({mobile_telephone:item.phone})
- that.$refs.KFB.setData({telephone:item.telephone})
- }
- })
- }
- if(that.processData.businessTable == 'bwg_meeting_summary'){//技能博物馆 --- 会议纪要---默认当前登陆人
- that.dynamicData.personListJn.map(item =>{
- if(item.label == that.$store.getters.nickname){
- that.$refs.KFB.setData({record_person:item.value})
- that.$refs.KFB.setData({record_department:item.departIds_dictText})
- }
- })
- }
- //技能博物馆-物料库存
- if(that.processData.businessTable == 'material_apply'){
- that.$refs.KFB.setData({department:jnDeparment})
- }
- //技能博物馆-物料申领
- if(that.processData.businessTable == 'application_form'){
- that.$refs.KFB.setData({department:jnDeparment})
- }
- //技能博物馆-任务--默认当前登陆人部门
- if(that.processData.businessTable == 'task_management'){
- that.$refs.KFB.setData({initiate_department:jnDeparment})
- }
- //技能博物馆-固定资产-报废
- if(that.processData.businessTable == 'scrap_apply'){
- that.$refs.KFB.setData({apply_personnel_department:jnDeparment})
- }
- },0)
- annualLeave({username:that.$store.getters.userInfo.username}).then(res => {
- if (res.success) {
- this.leave = res.result.nannualNowNum
- }else{
- this.$message.error(res.message);
- }
- })
- }else if(item[1].label =='automatic'){
- var that = this
- setTimeout(function(){
- // if(that.processData.businessTable == 'incident_ticket'){ // 森语-质量事故单-自动生成事故单号
- // // if( that.processData.tableId==''|| !that.processData.tableId){
- // // that.getAction('/sys/user/getNextNo',{name:'accidentCode'}).then(res => {
- // // that.$refs.KFB.setData({accident_number:res})
- // // })
- // // }
- // }else
- if(that.processData.businessTable == 'expense_account'){//报销单-自动生成单号
- if( that.processData.tableId==''|| !that.processData.tableId){
- that.getAction('/sys/user/getNextNo',{name:'BXDCode'}).then(res => {
- that.$refs.KFB.setData({reimbursement_no:res})
- })
- }
- }
- },200)
-
- }
- },
- // 获取申请人信息
- getApplicant () {
- console.log('aa', this.$refs.KFB.form.getFieldValue('applicant'))
- // if (this.$refs.KFB.form.getFieldValue('applicant')) {
- // alert(1)
- // this.$refs.KFB.setData({
- // applicant: this.$store.getters.userInfo.username
- // })
- // }
- },
- changedd(){
- window.print()
- },
- //主子表计算
- tableCalculation(value){
- if(this.processData.businessTable == 'supplieses_apply_a' ){
- var number1 = 0,
- number2 = 0
- //寻找help信息中对应的modol值
- this.bv.map(item=>{
- this.cvarr.map(vv=>{
- if(vv.key == item.bn[1].label){
- number1 = vv.model
- }else if(vv.key == item.bn[2].label){
- number2 = vv.model
- }
- })
- //表中每一行分别计算
- var sum = 0
- value.map(b=>{
- b[item.bn[0].label] = (b[number1]*b[number2]).toFixed(2)
- sum += b[number1]*b[number2] //计算出表格内的总价总和
- if(this.$store.getters.nickname=='崔崇杰'){
- b['procurement_type']='公司采购'
- }else if(b['procurement_type']=='' ||!b['procurement_type'] ){
- b['procurement_type']='部门采购'
- }
- })
- sum = sum.toFixed(2)
- this.$refs.KFB.setData({sum:sum})
- })
- }
- if(this.processData.businessTable == 'incident_ticket'){
- var all = 0,
- currencys=[],
- currency =''
- value.map(item=>{
- item.accident_sum = item.accident_sum?item.accident_sum:'0'
- //计算表头总价
- all+=Number(item.accident_sum)
- //币种-自动带出
- if(item.money_type){currencys.push(item.money_type)}
- })
- //获取表格中只出现一次的币种-即为改变的币种
- currencys.every(item=>{
- const countOccurences = (arr, value) => arr.reduce((a, v) => v === value ? a + 1 : a + 0, 0)
- if(countOccurences(currencys,item)==1){
- currency=item
- return false
- }
- return true
- })
- //赋值
- value.map(item=>{
- //若无只出现一次的币种 1.第一次表格增行 2.表格中有两条以上数据,再次增行
- if(currency==''){
- item.money_type = currencys[0]
- }else{
- item.money_type = currency
- }
-
- })
-
- this.$refs.KFB.setData({total_money:all})
- }
- },
- specialTerms(value,key){
- var that = this
- //剩余年假
- if(key == 'employe_name'){
- setTimeout(function(){
- annualLeave({username:value}).then(res => {
- if (res.success) {
- //选择姓名获取页面的请假类型和时间间隔
- that.leave = res.result.nannualNowNum
- that.$refs.KFB.setData({leave_remaining: that.leave})
- var category = that.$refs.KFB.form.getFieldValue('leave_category')
- var time1 = that.$refs.KFB.form.getFieldValue('start_date')
- var time2 = that.$refs.KFB.form.getFieldValue('end_date')
- var timeC=that.timeDifference(time1,time2,'min') //获取时间差
- //事假,超过180分钟,年假大于0.5
- if(category == '事假' &&timeC>=180&&that.leave>=0.5){
- that.$refs.KFB.setData({unit:'天'})
- that.$refs.KFB.setData({leave_category:'年假'})
- }else if(category == '年假' && that.leave<0.5){ //类型为年假,剩余年假小于0.5
- that.$refs.KFB.setData({unit:'分'})
- that.$refs.KFB.setData({leave_category:''})
- that.$message.error('剩余年假不足!');
- }
- }else{
- that.$message.error(res.message);
-
- }
- })
- },0)
- }
- //请假类型与单位
- //事假
- if(key == 'leave_category' && value == '事假'){
- setTimeout(function(){
- var time1 = that.$refs.KFB.form.getFieldValue('start_date')
- var time2 = that.$refs.KFB.form.getFieldValue('end_date')
- var timeC=that.timeDifference(time1,time2,'min') //获取时间差
- if(timeC>=180 && that.leave>=0.5){ //事假,时间差大于180,剩余年假大于0.5
- that.$refs.KFB.setData({unit:'天'})
- that.$refs.KFB.setData({leave_category:'年假'})
- }else{
- that.$refs.KFB.setData({unit:'分'})
- }
- },0)
- }else if(key == 'leave_category' && value == '病假'){ //病假
- setTimeout(function(){
- that.$refs.KFB.setData({unit:'分'})
- },0)
- }else if(key == 'leave_category' && value == '年假'){//年假
- setTimeout(function(){
- if(that.leave >=0.5){ //剩余年假大于0.5
- that.$refs.KFB.setData({unit:'天'})
- }else{ //剩余年假小于0.5
- that.$refs.KFB.setData({unit:'分'})
- that.$refs.KFB.setData({leave_category:''})
- that.$message.error('剩余年假不足!');
- }
- },0)
- }else if(key == 'leave_category'){
- setTimeout(function(){
- that.$refs.KFB.setData({unit:'天'})
- },0)
- }
- //时间间隔和类型
- if(key =='start_date' || key =='end_date'){
- setTimeout(function(){
- var time2 = that.$refs.KFB.form.getFieldValue('end_date')
- var time1 = that.$refs.KFB.form.getFieldValue('start_date')
- var timeC=that.timeDifference(time1,time2,'min')
- var lx=that.$refs.KFB.form.getFieldValue('leave_category')
- if(timeC>=180&&lx=='事假'&&that.leave>=0.5){ //事假,时间差大于180,剩余年假大于0.5
- that.$refs.KFB.setData({unit:'天'})
- that.$refs.KFB.setData({leave_category:'年假'})
- }
- },0)
-
- }
- },
- // 表单字段数值发生改变事件
- handleChange (value, key) {
- if(key == 'proposer' && this.processData.businessTable == 'regular_employee_apply'){//员工转正申请:申请人部门
- this.$refs.KFB.setData({apply_department:this.deptInfo[value]})
- }
- if(key == 'regular_employee' && this.processData.businessTable == 'regular_employee_apply'){//员工转正申请:转正人员岗位
- this.$refs.KFB.setData({job_title:this.postInfo[value]})
- }
- if(key == 'proposer' && this.processData.businessTable == 'seal_apply'){//用印申请单
- this.$refs.KFB.setData({apply_department:this.deptInfo[value]})
- }
- if(key == 'employee_name' && this.processData.businessTable == 'separation_application'){//离职申请
- this.$refs.KFB.setData({job_title:this.postInfo[value]})
- }
-
- //森语-质量事故单
- if(key=='child&incident_ticket_children'){
- this.tableCalculation(value)
-
- }
- //技能博物馆-----退休录入
- if(key == 'name' && this.processData.businessTable == 'bwg_retire_input'){//技能博物馆 ---- 退休录入
- this.dynamicData.personListJn.map(item =>{
- if(item.label == value){
- this.$refs.KFB.setData({employee_number:item.workNo})
- this.$refs.KFB.setData({post:item.post})
- this.$refs.KFB.setData({rz_date:item.nInductionTim})
- }
- })
- // this.$refs.KFB.setData({employee_number:this.postInfo[value]})
- }
- //技能博物馆-----离职录入
- if(key == 'name' && this.processData.businessTable == 'bwg_quit_input'){//技能博物馆 ---- 退休录入
- this.dynamicData.personListJn.map(item =>{
- if(item.label == value){
- this.$refs.KFB.setData({employee_number:item.workNo})
- this.$refs.KFB.setData({post:item.post})
- this.$refs.KFB.setData({rz_date:item.nInductionTim})
- }
- })
- }
- //技能博物馆 ----- 费用报销
- if(key == 'expense_person' && this.processData.businessTable == 'bwg_expense_apply'){
- this.dynamicData.personListJn.map(item =>{
- if(item.label == value){
- this.$refs.KFB.setData({expense_department:item.departIds_dictText})
- }
- })
- }
- // 技能博物馆---用车申请
- if(key == 'car_automobilist' && this.processData.businessTable == 'car_apply'){
- this.dynamicData.personListJn.map(item =>{
- if(item.label == value){
- this.$refs.KFB.setData({car_department:item.departIds_dictText})
- }
- })
- }
- // // 技能博物馆---物料库存--金额计算
- // if((key == 'unit_price'||key=='amount') && this.processData.businessTable == 'material_apply'){
- // var that = this
- // setTimeout(function(){
- // var unit_price = that.$refs.KFB.form.getFieldValue('unit_price'),
- // amount = that.$refs.KFB.form.getFieldValue('amount'),
- // sum = Number(unit_price)*Number(amount)
- // that.$refs.KFB.setData({money:sum})
- // },0)
- // }
- // 技能博物馆---物料库存--部门
- if(key == 'input_account' && this.processData.businessTable == 'material_apply'){
- this.dynamicData.personListJn.map(item =>{
- if(item.label == value){
- this.$refs.KFB.setData({department:item.departIds_dictText})
- }
- })
- }
- if(key == 'task_executor' &&this.processData.businessTable == 'task_management'){
- this.dynamicData.personListJn.map(item =>{
- if(item.label == value){
- this.$refs.KFB.setData({task_department:item.departIds_dictText})
- }
- })
- }
- // 技能博物馆---物料申领--部门
- if(key == 'get_account' && this.processData.businessTable == 'application_form'){
- this.dynamicData.personListJn.map(item =>{
- if(item.label == value){
- this.$refs.KFB.setData({department:item.departIds_dictText})
- }
- })
- }
- // 技能博物馆---固定资产--归还
- if(key == 'uuse_personnel' && this.processData.businessTable == 'give_back'){
- this.dynamicData.personListJn.map(item =>{
- if(item.label == value){
- this.$refs.KFB.setData({use_department:item.departIds_dictText})
- }
- })
- }
- //技能博物馆-固定资产-报废
- if(key == 'apply_personnel' &&this.processData.businessTable == 'scrap_apply'){
- this.dynamicData.personListJn.map(item =>{
- if(item.label == value){
- this.$refs.KFB.setData({apply_personnel_department:item.departIds_dictText})
- }
- })
- }
- //技能博物馆 ----资金审批
- if(key == 'project_name' && this.processData.businessTable == 'bwg_capital_approval'){
- this.dynamicData.fundApproval.map(item =>{
- if(item.label == value){
- this.$refs.KFB.setData({start_data:item.startDate})
- this.$refs.KFB.setData({end_date:item.endDate})
- this.$refs.KFB.setData({project_reasons:item.projectReasons})
- this.$refs.KFB.setData({budget_information:item.budgetInformation})
- }
- })
- }
-
- //改变的表单是主子表类型时----物质申请单
- if(key =='child&supplieses_apply'){
- this.tableCalculation(value)
- }
- //特别字段
- this.specialTerms(value,key)
- //代码赘余,日后维护
- //保存发生改变字段名对应的key
- var cc ='',
- type = ''
- this.cvarr.map(k =>{
- if(k.model ==key){
- cc=k.key
- type = k.type
- }})
- //根据数值改变计算
- var that =this
- setTimeout(function(){
- that.bv.map(event =>{
- if(event.bn[1].label == cc || event.bn[2].label == cc){
- that.cvarr.map(k=>{
- if(k.key == event.bn[1].label){
- event.bn[1].value = that.$refs.KFB.form.getFieldValue(k.model)
- }else if(k.key == event.bn[2].label){
- event.bn[2].value = that.$refs.KFB.form.getFieldValue(k.model)
- }
- })
- if(type == 'date'){
- if(event.bn[1].value!=='' && event.bn[2].value!==''){
- var state = ''
- state = event.bn[3].label
- event.bn[0].value = that.timeDifference(event.bn[1].value,event.bn[2].value,state)
- }
- }else{
- if(event.bn[3].label =="+"){
- event.bn[0].value = Number(event.bn[1].value)+Number(event.bn[2].value)
- }else if(event.bn[3].label =="-"){
- event.bn[0].value = Number(event.bn[1].value)-Number(event.bn[2].value)
- }else if(event.bn[3].label =="*"){
- event.bn[0].value = Number(event.bn[1].value)*Number(event.bn[2].value)
- }
- }
- that.$refs.KFB.setData({[event.bn[0].label]:event.bn[0].value})
- }
- })
-
- },0)
- // // 数据变化时触发
- // // 如果开始时间发生变化
- // if (key == 'start_time') {
- // // 判断结束时间是否存在
- // if (this.$refs.KFB.form.getFieldValue('end_time')) {
- // // 获取时间差
- // let duration = startEndFun(value, this.$refs.KFB.form.getFieldValue('end_time'))
- // if (duration) {
- // // 使用k-form-design组件的form属性修改表单数据
- // this.$refs.KFB.setData({
- // duration: duration
- // })
- // }
- // }
- // }
- // // 如果结束时间发生变化
- // if (key == 'end_time') {
- // // 判断结束时间是否存在
- // if (this.$refs.KFB.form.getFieldValue('start_time')) {
- // // 获取时间差
- // let duration = startEndFun(this.$refs.KFB.form.getFieldValue('start_time'), value)
- // if (duration) {
- // // 使用k-form-design组件的form属性修改表单数据
- // this.$refs.KFB.setData({
- // duration: duration
- // })
- // }
- // }
- // }
- },
- // handler
- handleSubmit (e) {
- var that =this
- // return new Promise((resolve)=>{
- // 通过函数获取数据
- this.$refs.KFB.getData()
- .then(async(res) => {
- // let formData1 = JSON.parse(JSON.stringify(res))
- // // 获取数据成功
- // let formData = JSON.parse(JSON.stringify(res))
- let formData1 = JSON.parse(JSON.stringify(res, (key, value) => typeof value === 'undefined' ? '' : value))
- // 获取数据成功
- let formData = JSON.parse(JSON.stringify(res, (key, value) => typeof value === 'undefined' ? '' : value))
-
- var addForm = 'no'
- if(this.processData.businessTable == 'employee_leave'){
- var estimate = this.$refs.KFB.form.getFieldValue('leave_days'),
- // actual = that.$refs.KFB.form.getFieldValue('practical_leave'),
- leaveCategory = this.$refs.KFB.form.getFieldValue('leave_category')
- if(leaveCategory=='年假' && !estimate){
- this.$message.error('请填写预计请假天数!')
- addForm = 'yes'
- }
- if(estimate>this.leave && leaveCategory=='年假'){
- this.$message.error('预计请假年假'+estimate+'大于剩余年假'+this.leave)
- addForm = 'yes'
- }
- }
- if(this.processData.businessTable == 'incident_ticket'){
- var sonTable=[]
- // 获取子表数据
- _.keys(formData1).forEach(r => {
- if (r.indexOf('child&') != -1) {
- sonTable=formData1[r]
- }
- })
- if(sonTable!==''){
-
- }
- var supplier = this.$refs.KFB.form.getFieldValue('responsibility_company')
- var responsibility1 = this.$refs.KFB.form.getFieldValue('responsibility_person1')
- if(sonTable==''){
- this.$message.error('计划单号未填写!')
- addForm = 'yes'
- }else{
- var all = 0,
- PlanNum=[]
- sonTable.map(item=>{
- item.accident_sum = item.accident_sum?item.accident_sum:'0'
- all+= Number(item.accident_sum)
- PlanNum.push(item.plan_number)
- })
- formData.total_money = Number(all).toFixed(2)
- formData.plan_number = PlanNum.toString()
- sonTable.every(item=>{
- if(item.accident_type=='不涉及金额' && item.accident_sum !=='0'){
- this.$message.error('事故类型为不涉及金额时事故金额应为0!')
- item.accident_sum = item.accident_sum
- addForm = 'yes'
- return false
- }
- return true
- })
- if((!supplier||supplier=='') && (!responsibility1 || responsibility1=='')){
- this.$message.error('责任人和责任单位必填其一')
- addForm = 'yes'
- }
- if(supplier&&supplier!==''){
- var type = this.$refs.KFB.form.getFieldValue('business_type')
- var factory = this.$refs.KFB.form.getFieldValue('factory_signature')
- if(!type|| type==''){
- this.$message.error('请选择业务类型')
- // 边框变红
- let div1 = document.getElementById('business_type')
- div1.setAttribute('class', 'active')
- addForm = 'yes'
- }else if(!factory || factory==''){
- sonTable.every(item=>{
- if(item.accident_type=='扣款'){
- this.$message.error('请上传工厂签章')
- addForm = 'yes'
- return false
- }
- return true
- })
-
- }
- }
- if(responsibility1&&responsibility1!==''){
- var responsibility2 = this.$refs.KFB.form.getFieldValue('responsibility_person2')
- var responsibility3 = this.$refs.KFB.form.getFieldValue('responsibility_person3')
- var responsibility4 = this.$refs.KFB.form.getFieldValue('responsibility_person4')
- var sum1 = this.$refs.KFB.form.getFieldValue('sum1')
- var sum2 = this.$refs.KFB.form.getFieldValue('sum2')
- var sum3 = this.$refs.KFB.form.getFieldValue('sum3')
- var sum4 = this.$refs.KFB.form.getFieldValue('sum4')
-
- var dd =[
- {responsibility:responsibility1,sum:sum1,index:1},
- {responsibility:responsibility2,sum:sum2,index:2},
- {responsibility:responsibility3,sum:sum3,index:3},
- {responsibility:responsibility4,sum:sum4,index:4},
- ]
- dd.every(item=>{
- if( (item.sum===''||item.sum== undefined ||item.sum== null )){
- this.$message.error('请填写金额'+item.index)
- addForm = 'yes'
- return false
- }
- return true
- })
- }
- }
-
- }
-
- // 处理手机端子表数据
- if (this.isSJ) {
- this.itemData(res)
- }
- // 清除为空的表单数据
- _.keys(res).forEach(r => {
- if (!res[r]) {
- delete res[r]
- }
- })
- console.log(formData)
- formData.id = this.data.id
- formData.procDefId = this.processData.id
- formData.procDeTitle = this.processData.name
-
- if (!formData.tableName) formData.tableName = this.processData.businessTable
- formData.filedNames = _.keys(formData1).join(',')
- formData.filedNames = getFiledNames(formData) // 获取主表字段,排除子表标识
- var url = this.url.addApply
- if (!this.isNew) {
- url = this.url.editForm
- }
- // 是否存在子表
- let ischild = false
- // 循环表单字段属性判断是否属性中包含数组对象
- let i = 0 // 子表数量
- _.keys(res)
- .join(',')
- .split(',')
- .forEach(element => {
- if (formData[element] instanceof Array) {
- // 判断是否符合子表命名规则
- if (element.indexOf('&') != -1) {
- let tableChildNameList = element.split('&')
- // 判断是否能拆分两个字符,子表标识和子表数据库名称
- if (tableChildNameList.length == 2) {
- i++
- let childName = tableChildNameList[1] // 子表数据库名称
- if (!formData.table_name_children) {
- // 第一次拼接
- formData.table_name_children = childName // 表名
- } else {
- // 后面的表明拼接用“,”隔开
- formData.table_name_children = formData.table_name_children + ',' + childName // 表名
- }
- // 定义属性名和值
- formData['childFiledNames' + i] = _.keys(formData[element][0]).join(',') // 子表字段名
- formData['childList' + i] = JSON.stringify(formData[element]) // 子表数据
- ischild = true
- }
- } else {
- // 如果不是子表则是上传文件,则转字符串
- formData[element] = JSON.stringify(formData[element])
- }
- }
- // formData[element];
- })
- // 判断需不需要存子表
- if (ischild) {
- formData.filedNames = formData.filedNames + ',table_name_children'
- }
- console.log(formData)
- // 子表数据
- // 调用保存接口
- this.todoManageOperationObject.formData = formData
- this.todoManageOperationObject.url = url
- // formData.jsonContent=JSON.stringify(this.jsonData).toString()
- // 获取是否部门负责人
- formData.filedNames = formData.filedNames + ',is_leaders'
- // formData.is_leaders = this.$store.getters.userInfo.identity
- formData.is_leaders = this.$store.getters.userInfo.isPossess
- // 清除子表规则的属性
- _.keys(formData).forEach(r => {
- if (r.indexOf('child&') != -1) {
- delete formData[r]
- }
- })
- // 如果手机端子表得则需要修改json
- // var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
- var jsonPamats = JSON.parse(JSON.stringify(this.jsonDataSave))
- if (!this.isSJ && this.isNew) {
- jsonPamats = null
- }
- this.todoManageOperationObject.jsonData = jsonPamats
- // 非我的待办节点打卡表单界面
- if(addForm=='no'){
- if(this.processData.businessTable == 'incident_ticket'){ // 森语-质量事故单-自动生成事故单号
- if( this.processData.tableId==''|| !this.processData.tableId){
- await this.getAction('/sys/user/getNextNo',{name:'accidentCode'}).then(res => {
- formData.accident_number = res
- })
- }
- }
- this.btndisabled = true
- await postFormDataAction(url, formData, { jsonContent: jsonPamats })
- .then(res => {
- if (res.success) {
- this.todoManageOperationObject.isSave = true
- this.$message.success('保存成功!')
- console.log('123')
- this.$emit('afterSubmit', formData)
- this.$emit('close')
- // resolve(true);
- } else {
- this.$message.error(res.message)
- // resolve(false);
- }
- })
- .finally(() => {
- this.btndisabled = false
- // resolve(false);
- })
- }
- })
- .catch(err => {
- console.log(err, '校验失败')
- // resolve(false);
- })
- // })
- },
- // 我的待办点击通过保存专用
- handleSubmit2 (e) {
- // return new Promise((resolve)=>{
- // 通过函数获取数据
- this.$refs.KFB.getData()
- .then(res => {
- // 处理手机端子表数据
- if (this.isSJ) {
- this.itemData(res)
- }
- // 清除为空的表单数据
- _.keys(res).forEach(r => {
- if (!res[r]) {
- delete res[r]
- }
- })
- // 获取数据成功
- let formData = JSON.parse(JSON.stringify(res))
- console.log(formData)
- formData.id = this.data.id
- formData.procDefId = this.processData.id
- formData.procDeTitle = this.processData.name
- // formData.jsonContent=JSON.stringify(this.jsonData)
- if (!formData.tableName) formData.tableName = this.processData.businessTable
- formData.filedNames = _.keys(res).join(',')
- formData.filedNames = getFiledNames(formData) // 获取主表字段,排除子表标识
- var url = this.url.addApply
- if (!this.isNew) {
- url = this.url.editForm
- }
- // 是否存在子表
- let ischild = false
- // 循环表单字段属性判断是否属性中包含数组对象
- let i = 0 // 子表数量
- _.keys(res)
- .join(',')
- .split(',')
- .forEach(element => {
- if (formData[element] instanceof Array) {
- // 判断是否符合子表命名规则
- if (element.indexOf('&') != -1) {
- let tableChildNameList = element.split('&')
- // 判断是否能拆分两个字符,子表标识和子表数据库名称
- if (tableChildNameList.length == 2) {
- i++
- let childName = tableChildNameList[1] // 子表数据库名称
- if (!formData.table_name_children) {
- // 第一次拼接
- formData.table_name_children = childName // 表名
- } else {
- // 后面的表明拼接用“,”隔开
- formData.table_name_children = formData.table_name_children + ',' + childName // 表名
- }
- // 定义属性名和值
- formData['childFiledNames' + i] = _.keys(formData[element][0]).join(',') // 子表字段名
- formData['childList' + i] = JSON.stringify(formData[element]) // 子表数据
- ischild = true
- }
- } else {
- // 如果不是子表则是上传文件,则转字符串
- formData[element] = JSON.stringify(formData[element])
- }
- }
- // formData[element];
- })
- // 判断需不需要存子表
- if (ischild) {
- formData.filedNames = formData.filedNames + ',table_name_children'
- }
- console.log(formData)
- // 子表数据
- // 调用保存接口
- this.btndisabled = true
- this.todoManageOperationObject.formData = formData
- this.todoManageOperationObject.url = url
- // 获取是否部门负责人
- formData.filedNames = formData.filedNames + ',is_leaders'
- // formData.is_leaders = this.$store.getters.userInfo.identity
- formData.is_leaders = this.$store.getters.userInfo.isPossess
- // 清除子表规则的属性
- _.keys(formData).forEach(r => {
- if (r.indexOf('child&') != -1) {
- delete formData[r]
- }
- })
- // 如果手机端子表得则需要修改json
- // var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
- var jsonPamats = JSON.parse(JSON.stringify(this.jsonDataSave))
- if (!this.isSJ && this.isNew) {
- jsonPamats = null
- }
- this.todoManageOperationObject.jsonData = jsonPamats
- })
- .catch(err => {
- console.log(err, '校验失败')
- // resolve(false);
- })
- // })
- },
- close () {
- this.$emit('close')
- },
- getData () {
- // 通过函数获取数据
- this.$refs.KFB.getData()
- .then(res => {
- // 获取数据成功
- alert(JSON.stringify(res))
- })
- .catch(err => {
- console.log(err, '校验失败')
- })
- },
- // 刷新待办列表
- refreshToDo () {
- this.close()
- this.$emit('getDataList')
- },
- itemData (res) {
- var childName = '' // 子表规则名称
- var itemIndex = 0
- this.jsonData.list.forEach((element, index) => {
- if (element.label.indexOf('child&') != -1) {
- childName = element.label // 获取规则名
- itemIndex = itemIndex + 1
- }
- })
- var itemList = [] // 封装子表数据
- for (var i = 1; i <= itemIndex; i++) {
- var itemObject = {} // 子表对象
- this.itemModelNameList.forEach(name => {
- // 获取子表得值和封装对象
- itemObject[name] = res[name + '@' + i]
- delete res[name + '@' + i]
- })
- itemList.push(itemObject)
- }
- res[childName] = itemList // 完成子表数据封装
- console.log(res)
- },
- deleteRow (idIndex) {
- // 删除
- this.jsonData.list.splice(idIndex, 1)
- // 删除掉得json之后 重新处理model 和value
- let childIndex = 0
- this.jsonData.list.forEach((element, index) => {
- if (element.label.indexOf('child&') != -1) {
- childIndex = childIndex + 1
- // 只有当前删除的对象json的后面对象json才进行修改
- if (index >= idIndex) {
- // 修改删除按钮的index
- element.columns[0].list[1].options.defaultValue =
- '<a href="javascript:void(0);" \n onclick="deleteRow(' + childIndex + ')">删除</a>'
- // 修改model
- updateModel(element, childIndex)
- // 需要调整的子表值
- var updateModelObject = {}
- // 修改value
- this.$refs.KFB.getData().then(res => {
- // 根据原始字段名拼接带规则的
- this.itemModelNameList.forEach(modelName => {
- updateModelObject[modelName + '@' + childIndex] = res[modelName + '@' + (childIndex + 1)]
- })
- this.$refs.KFB.setData(updateModelObject)
- })
- }
- }
- })
- console.log(JSON.stringify(this.jsonData.list))
- },
- add () {
- let childLable = '' // 子表json标题
- let childValue = {} // 新增子表json
- let isReturn = false
- let childIndex = 0
- var itemList = []
- this.jsonData.list.forEach((element, index) => {
- if (element.label.indexOf('child&') != -1) {
- childValue = JSON.parse(JSON.stringify(element))
- childLable = element.label
- // 处理删除按钮
- childIndex = childIndex + 1
- // element.columns[0].list[1].options.dynamicFun = 'delete' + childIndex
- console.log(element.columns[0].list[1].options)
- element.columns[0].list[1].options.defaultValue =
- '<a href="javascript:void(0);" \n onclick="deleteRow(' + childIndex + ')">删除</a>'
- updateModel(childValue, childIndex)
- }
- if (!isReturn && childLable != '' && element.label != childLable) {
- isReturn = true
- // 处理删除按钮
- childIndex = childIndex + 1
- // childValue.columns[0].list[1].options.dynamicFun = 'delete' + childIndex
- childValue.columns[0].list[1].options.defaultValue =
- '<a href="javascript:void(0);" \n onclick="deleteRow(' + childIndex + ')">删除</a>'
- updateModel(childValue, childIndex)
- // this.jsonData.list.splice(index, 0, childValue)
- itemList.push(childValue)
- }
- itemList.push(element)
- })
- this.jsonData.list = itemList
- console.log(JSON.stringify(this.jsonData.list))
- },
- // 把整个子表json的model进行规则修改
- async listUpdateModel () {
- let modelIndex = 0 // 子表model自增
- // 循环整个json的表单
- this.jsonData.list.forEach((element, index) => {
- // 找到为子表的json
- if (element.label.indexOf('child&') != -1) {
- this.isSJ = true
- // 获取子表原始得model字段名
- if (modelIndex == 0) {
- var i = 1
- var itemString = JSON.stringify(element)
- var itemModelNameList = [] // 储存子表字段名
- for (var i = 1; i !== -1;) {
- // 动态字符位置
- i = itemString.indexOf('"model"', i)
- if (i !== -1) {
- // 从指定字符的周后一个字符后开始找(")
- var ihStart = itemString.indexOf('"', i + 7)
- // 再从 (") 后面位置还是找下一个 (")
- var ihEnd = itemString.indexOf('"', ihStart + 1)
- // 获取引号之间的字符
- var model = itemString.substring(ihStart + 1, ihEnd)
- // 如果动态表示不为空则获取
- if (model != '') {
- if (model.indexOf('@') != -1) {
- model = model.substring(0, model.length - 2)
- }
- itemModelNameList.push(model)
- }
- i = ihEnd + 1
- }
- }
- this.itemModelNameList = itemModelNameList
- }
- modelIndex = modelIndex + 1
- // 修改model
- updateModel(element, modelIndex)
- }
- })
- },
- //计算时间差
- timeDifference(start, end,state){
- if(getProjctName() =='技能博物馆'){
- var startDayArr = start.split(' '),
- startDay = startDayArr[0]+' '+'16:00'
- // 计算出请假第一天距离下班多久
- var s1 = new Date(start.replace(/-/g, '/')),
- s2 = new Date(startDay.replace(/-/g, '/')),
- ms = Math.abs(s1.getTime() - s2.getTime()),
- mins= (ms / 1000 / 60 / 60);
- // ___________
- var endDayArr = end.split(' '),
- endDay = endDayArr[0]+' '+'9:00'
- // 计算出请假最后一天距离上班多久
- var s11 = new Date(end.replace(/-/g, '/')),
- s22 = new Date(endDay.replace(/-/g, '/')),
- ms2 = Math.abs(s11.getTime() - s22.getTime()),
- mins2= (ms2 / 1000 / 60 / 60);
- // ————————
- var startDay = new Date(start),
- endDay = new Date(end),
- startDateTime=new Date(startDay.setDate(startDay.getDate()+1));
- startDateTime =(moment(startDateTime).format('YYYY-MM-DD HH:mm')).split(' ')
- var EndDateTime=new Date(endDay.setDate(endDay.getDate()-1));
- EndDateTime =(moment(EndDateTime).format('YYYY-MM-DD HH:mm')).split(' ')
- var myDate_1 = Date.parse(EndDateTime[0]),
- myDate_2 = Date.parse(startDateTime[0])
- //计算除去第一天和最后一天后相差多少天
- var diffDate = Math.abs(myDate_1 - myDate_2), // 取相差毫秒数的绝对值
- totalDays = Math.floor(diffDate / (1000 * 3600 * 24))+1 // 向下取整
- if(startDateTime>EndDateTime){
- totalDays = 0
- }
- var dayTime = (totalDays+(mins+mins2)/8).toFixed(1)
- return dayTime
- }else{
- // if(start>end){
- // this.$message.error('起始时间不可大于结束时间');
- // }else{
- let beginTime = (new Date(start).getTime()) / 1000;
- let endTime = (new Date(end).getTime()) / 1000;
- //计算天数
- var timediff = endTime - beginTime;
- var days = parseInt(timediff / 86400); //60*60*24
- //计算小时数
- var remain = timediff % 86400 ;
- var hours = parseInt(remain / 3600);
- //计算分钟数
- var remain = remain % 3600;
- var mins = parseInt(remain / 60);
- var res = days + '天' + hours + '小时' + mins + '分';
- if(state == 'min'){
- return days*24*60+hours*60+mins
- }else if(state == 'hour'){
- return days*24+hours+mins/60
- }else if(state == 'day'){
- if(start.split(' ').length==1 && end.split(' ').length == 1){
- return days+1+hours/24+mins/60/24
- }else{
- return days+hours/24+mins/60/24
- }
-
- }else if(state == 'day/hour/min'){
- return days+'天'+hours+'小时'+mins+'分'
- }else if(state == 'hour/min'){
- return (days*24+hours)+'小时'+mins+'分'
- }
- }
- }
- }
- // }
- }
- // 获取主表字段,排除子表标识
- function getFiledNames (formData) {
- let filedNames = ''
- let list = formData.filedNames.split(',') // 获取表单属性名集合
- list.forEach(element => {
- if (element.indexOf('&') == -1) {
- // 查询是否有这个字段
- if (filedNames == '') {
- // 第一次则直接等于
- filedNames = element
- } else {
- // 后面用逗号隔开
- filedNames = filedNames + ',' + element
- }
- }
- })
- return filedNames
- }
- // 根据开始时间 结束时间计算天数
- function startEndFun (start, end) {
- let startTime = new Date(start)
- let endTime = new Date(end)
- if (startTime >= endTime) {
- return 0
- }
- // 1,分钟取整
- startTime = carryTime(startTime)
- endTime = carryTime(endTime)
- // 2,计算总天数
- var totalTime = 0 // 工时,天数
- if (startTime.getDay() == 6 || startTime.getDay() == 0) {
- totalTime = endTime.getDate() - startTime.getDate()
- } else {
- totalTime = Math.floor((endTime - startTime) / (3600 * 1000) / 24)
- }
- // 3,拿初始值赋值给一个临时变量
- var tempStartTime = new Date()
- tempStartTime.setTime(startTime.getTime())
- // 4,计算出总天数
- while (tempStartTime.getDate() < endTime.getDate()) {
- if (tempStartTime.getDay() == 6 || tempStartTime.getDay() == 0) {
- // 周六或者周日减去
- totalTime--
- }
- tempStartTime.setDate(tempStartTime.getDate() + 1)
- }
- // 5,计算出总小时数
- var temp = 0 // 工时,小时
- do {
- if (startTime.getDay() == 6 || startTime.getDay() == 0) {
- // 周六周日
- startTime.setDate(startTime.getDate() + 1)
- //* ********周六周日直接跳过,初始化为早晨9点
- startTime.setHours(9)
- startTime.setMinutes(0)
- continue
- }
- if (endTime.getDay() == 6 || endTime.getDay() == 0) {
- // 周六周日
- endTime.setDate(endTime.getDate() + 1)
- //* ********周六周日直接跳过,初始化为早晨9点
- endTime.setHours(9)
- endTime.setMinutes(0)
- continue
- }
- let tempMinutes = startTime.getHours() * 60 + startTime.getMinutes()
- // 上午9点到12点半,算工时
- if (tempMinutes >= 9 * 60 && tempMinutes < 12 * 60) {
- temp += 0.05
- }
- // 上午14点到18点半,算工时
- if (tempMinutes >= 13 * 60 && tempMinutes < 18 * 60) {
- temp += 0.05
- }
- startTime.setTime(startTime.getTime() + 0.5 * 3600 * 1000) // 每次增加半个小时
- } while (startTime.getHours() * 60 + startTime.getMinutes() != endTime.getHours() * 60 + endTime.getMinutes())
- {
- totalTime += Math.floor(temp / 0.8)
- totalTime += temp % 0.8
- totalTime = Math.round(totalTime * 100) / 100
- }
- var days = Math.floor(totalTime)
- var hours = Math.round((totalTime - days) * 100) / 10
- console.log(days + '天', hours + '小时')
- return days * 8 + hours
- // if (start && end) {
- // let startTime = new Date(start) // 开始时间
- // let endTime = new Date(end) // 结束时间
- // let usedTime = endTime - startTime // 相差的毫秒数
- // let days = (usedTime / 1000 / 60 / 60).toFixed(2) // 计算出天数
- // return days
- // } else {
- // return null
- // }
- }
- // 格式化时间
- function formatDate (date, fmt) {
- if (/(y+)/.test(fmt)) {
- fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
- }
- let o = {
- 'M+': date.getMonth() + 1,
- 'd+': date.getDate(),
- 'h+': date.getHours(),
- 'm+': date.getMinutes(),
- 's+': date.getSeconds()
- }
- for (let k in o) {
- if (new RegExp(`(${k})`).test(fmt)) {
- let str = o[k] + ''
- fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : padLeftZero(str))
- }
- }
- return fmt
- }
- function padLeftZero (str) {
- return ('00' + str).substr(str.length)
- }
- /*
- * 0-15分不算工时
- * 15-45算半个小时
- * 45-60算一个小时
- * */
- function carryTime (date) {
- if (date.getMinutes() > 0 && date.getMinutes() < 15) {
- date.setMinutes(0)
- }
- if (date.getMinutes() >= 15 && date.getMinutes() < 30) {
- date.setMinutes(30)
- }
- if (date.getMinutes() > 30 && date.getMinutes() < 45) {
- date.setMinutes(30)
- }
- if (date.getMinutes() >= 45) {
- date.setHours(date.getHours() + 1)
- date.setMinutes(0)
- }
- return date
- }
- // function
- /**
- * 修改model绑定值
- */
- function updateModel (object, childIndex) {
- let keyString = _.keys(object).join(',')
- if (keyString.indexOf('model') != -1) {
- // 如果没有修改过则直接修改
- if (object['model'].indexOf('@') == -1) {
- object['model'] = object['model'] + '@' + childIndex
- } else {
- // 修改过则截取修改前的再进行修改
- var m = object['model'].substring(0, object['model'].length - 2)
- object['model'] = m + '@' + childIndex
- }
- }
- // 递归
- _.keys(object)
- .join(',')
- .split(',')
- .forEach(l => {
- if (object[l] instanceof Array) {
- object[l].forEach(element => {
- updateModel(element, childIndex)
- })
- }
- })
- }
- </script>
- <style lang="less" scoped>
- @media print {
- @page {
- /* 横向 */
- size: landscape;
- /* 去除浏览器默认页眉页脚 */
- margin: 0;
-
- }
- * {
- -webkit-print-color-adjust: exact !important; /* Chrome, Safari */
- color-adjust: exact !important; /*Firefox*/
- }
- .noprint {
- display: none;
- }
- /deep/ .ant-select-selection--multiple .ant-select-selection__rendered>ul>li, .ant-select-selection--multiple>ul>li{
- font-size: 14px!important;
- border: 0px solid black!important;
- min-width: 150px!important;
- height: 25!important;
- }
- /deep/ .ant-select-selection__choice__remove{
- display: none;
- }
- // /deep/.ant-input{
- // border: none !important;
- // }
- // /deep/ .ant-modal-header{
- // display: none !important;
- // }
- // /deep/ .ant-modal-content{
- // box-shadow:none !important
- // }
-
- /deep/ * {
- color: #000000!important;
- -webkit-tap-highlight-color: #000000!important;
- }
- /*update_end author:scott date:20191203 for:打印机打印的字体模糊问题 */
-
- /deep/ .abcdefg .ant-card-body{
- margin-left: 0%;
- margin-right: 0%;
- margin-bottom: 1%;
- border:0px solid black;
- min-width: 800px;
- color:#000000!important;
- }
- /deep/ .explain{
- text-align: left;
- margin-left: 50px;
- color:#000000!important;
- }
- /deep/ .explain .ant-input,.sign .ant-input{
- font-weight:bolder;
- text-align:center;
- border-left-width:0px!important;
- border-top-width:0px!important;
- border-right-width:0px!important;
- }
- /deep/ .explain div{
- margin-bottom: 10px;
- }
- /* you can make up upload button and sample style by using stylesheets */
- /deep/ .ant-upload-select-picture-card i {
- font-size: 32px;
- color: #999;
- }
-
- /deep/ .ant-upload-select-picture-card .ant-upload-text {
- margin-top: 8px;
- color: #666;
- }
- }
- /deep/ .anticon-question-circle-o {
- display: none !important;
- }
- /deep/ textarea#presentation_condition {
- height: 290px;
- }
- /deep/ textarea#expense_reason {
- height: 290px;
- }
- /deep/ textarea#meeting_content {
- height: 290px;
- }
- /deep/ .active .ant-select-selection {
- border: 1px solid red;
- }
- </style>
|