index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. <template>
  2. <!-- <el-row class="row-bg"> -->
  3. <el-col :span="ieug !== null? ieug : 8 " >
  4. <el-form-item label-width="140px" :label="formConfig.columnComment" style="display: inline-block;" :prop="formConfig.columnName">
  5. <!-- 输入框 -->
  6. <el-input v-if="formConfig.htmlType == 'input'" @change="iChange" v-model="config[formConfig.columnName]" :placeholder="'请输入'+formConfig.columnComment"
  7. clearable @keyup.enter.native="handleQuery" :disabled="formConfig.disabshow" />
  8. <!-- 多行输入框 -->
  9. <el-input v-if="formConfig.htmlType == 'textarea'" @change="iChange" type="textarea" v-model="config[formConfig.columnName]"
  10. :placeholder="'请输入'+formConfig.columnComment" clearable @keyup.enter.native="handleQuery" :disabled="formConfig.disabshow" />
  11. <!-- 下拉框 -->
  12. <el-select v-model="config[formConfig.columnName]" v-if="formConfig.htmlType == 'select'&&(!formConfig.fkInfo)"
  13. filterable :placeholder="'请输入'+formConfig.columnComment" :disabled="formConfig.disabshow">
  14. <el-option v-for="itemChild in formConfig.sysDictData" :key="itemChild.dictValue" :label="itemChild.dictLabel"
  15. :value="itemChild.dictValue">
  16. </el-option>
  17. </el-select>
  18. <!-- 下拉框搜索 -->
  19. <el-select :disabled="formConfig.disabshow" v-model="config[formConfig.columnName]" v-if="formConfig.htmlType == 'select'&&(formConfig.fkInfo)"
  20. filterable remote :remote-method="remoteMethod" :loading="loading" :placeholder="'请输入'+formConfig.columnComment">
  21. <el-option v-for="itemChild in filterList" :key="itemChild[formConfig.fkInfo.fkColumnName]" :label="itemChild[formConfig.fkInfo.dkColumnName]"
  22. :value="itemChild[formConfig.fkInfo.fkColumnName]">
  23. </el-option>
  24. </el-select>
  25. <!-- 树形结构 -->
  26. <div v-if="formConfig.htmlType == 'cascader'&&(!formConfig.fkInfo)">
  27. <el-cascader
  28. v-model="config[formConfig.columnName]"
  29. :options="formConfig.sysDictData"
  30. :placeholder="'请选择'+formConfig.columnComment"
  31. @getCheckedNodes = 'getCheckedNodes'
  32. @change="handleChangety(config[formConfig.columnName])"
  33. :props="{checkStrictly: true,value:'dictValue',label:'dictLabel',children: 'children'}"
  34. ></el-cascader>
  35. </div>
  36. <!-- <div class="head-container" > -->
  37. <!-- <div class="head-container">
  38. <el-tree
  39. :data="deptOptions"
  40. :props="defaultProps"
  41. :expand-on-click-node="false"
  42. :filter-node-method="filterNode"
  43. ref="tree"
  44. node-key="id"
  45. :current-node-key="5"
  46. @node-click="handleNodeClick"
  47. :highlight-current = 'true'
  48. :default-expanded-keys="[2, 3]"
  49. />
  50. </div> -->
  51. <!-- <treeselect v-model="config[formConfig.columnName]" :options="deptOptionsthre" :normalizer="normalizerty" :flat="true" @select="djieskletwo" :maxHeight="350" :placeholder="'请输入'+formConfig.columnComment" /> -->
  52. <!-- 复选框 -->
  53. <el-checkbox-group :disabled="formConfig.disabshow" v-model="config" v-if="formConfig.htmlType == 'checkbox'">
  54. <el-checkbox @change="handleCheckedCitiesChange" v-for="itemChild in formConfig.sysDictData" :label="itemChild.dictValue"
  55. :key="itemChild.dictLabel">
  56. {{itemChild.dictLabel}}
  57. </el-checkbox>
  58. </el-checkbox-group>
  59. <!-- 单选框 -->
  60. <el-radio-group :disabled="formConfig.disabshow" v-model="config[formConfig.columnName]" v-if="formConfig.htmlType == 'radio'">
  61. <el-radio v-for="itemChild in formConfig.sysDictData" :key="itemChild.dictValue" :label="itemChild.dictValue">{{itemChild.dictLabel}}</el-radio>
  62. </el-radio-group>
  63. <!-- 时间控件日期 -->
  64. <el-date-picker :disabled="formConfig.disabshow" @change="iChange" v-model="config[formConfig.columnName]" v-if="formConfig.htmlType == 'datetime-date'"
  65. type="date" :placeholder="'请输入'+formConfig.columnComment">
  66. </el-date-picker>
  67. <!-- 时间控件小时分钟 -->
  68. <el-date-picker :disabled="formConfig.disabshow" @change="iChange" v-model="config[formConfig.columnName]" v-if="formConfig.htmlType == 'datetime'"
  69. type="datetime" :placeholder="'请输入'+formConfig.columnComment" value-format="yyyy-MM-dd hh:mm:ss" >
  70. </el-date-picker>
  71. <!-- 上传图片 -->
  72. <el-upload :disabled="formConfig.disabshow" v-if="formConfig.htmlType == 'imageUpload'" :headers="{Authorization: 'Bearer ' + getToken()}"
  73. :action="process + '/boman-file/upload'" :file-list="config" list-type="picture-card" :on-preview="handlePictureCardPreview"
  74. :on-success="upImageFn" :on-remove="reseImage">
  75. <i class="el-icon-plus"></i>
  76. </el-upload>
  77. <el-dialog :disabled="formConfig.disabshow" :visible.sync="dialogVisible" v-if="formConfig.htmlType == 'imageUpload'">
  78. <img :src="dialogImageUrl" alt="">
  79. </el-dialog>
  80. <!-- 上传文件 -->
  81. <el-upload :disabled="formConfig.disabshow" class="upload-demo" :headers="{Authorization: 'Bearer ' + getToken()}"
  82. v-if="formConfig.htmlType == 'fileUpload'" :action="process + '/boman-file/upload'" :on-change="handleChange"
  83. :on-success="upImageFn" :on-error="err" :on-remove="reseImage" :file-list="config">
  84. <el-button size="small" type="primary">点击上传</el-button>
  85. <div slot="tip" class="el-upload__tip">只能上传jpg/png/txt/word/pdf/exe/RAR/ZIP文件,且不超过10MB</div>
  86. </el-upload>
  87. <!-- 富文本 -->
  88. <editor :disabled="formConfig.disabshow" v-model="config[formConfig.columnName]" v-if="formConfig.htmlType == 'editor'"
  89. :min-height="192" />
  90. </el-form-item>
  91. </el-col>
  92. <!-- </el-row> -->
  93. </template>
  94. <script>
  95. const defaultSettings = require('@/settings.js')
  96. import Editor from '@/components/Editor';
  97. import {
  98. listIndexfou,listIndextime
  99. } from "@/api/tool/gen";
  100. import {getUserProfile, } from "@/api/system/config";
  101. import {
  102. getToken
  103. } from "@/utils/auth";
  104. import { treeselect } from "@/api/system/dept";
  105. import Treeselect from "@riophae/vue-treeselect";
  106. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  107. export default {
  108. components: { Treeselect},
  109. data() {
  110. return {
  111. fileList: [],
  112. defaultSettings,
  113. dialogImageUrl: '',
  114. process: process.env.VUE_APP_BASE_API,
  115. dialogVisible: false,
  116. disabled: false,
  117. loading: false,
  118. filterList: [],
  119. value:[],
  120. config: {},
  121. aliemg: {
  122. table: '',
  123. orderBy: 'create_time desc',
  124. pageNo: 1,
  125. pageSize: 10,
  126. fixedData: {
  127. condition: {}
  128. },
  129. ieug:8
  130. },
  131. // 部门名称
  132. deptName: undefined,
  133. defaultProps: {
  134. children: 'children',
  135. label: 'label'
  136. },
  137. huetge:{},
  138. leavefrom_starttime:{
  139. leavefrom_start_time:undefined
  140. },
  141. leavefrom_end:{
  142. leavefrom_end_time:undefined
  143. },
  144. deptOptions: [],
  145. oieutgs:[],
  146. shoeuw:true,
  147. jueg:0
  148. }
  149. },
  150. components: {
  151. Editor
  152. },
  153. props: {
  154. queryData: {
  155. type: Object,
  156. default: res => {
  157. return {
  158. showData: []
  159. }
  160. }
  161. },
  162. formConfig: {
  163. type: Object,
  164. required: true,
  165. 'default': {
  166. sysDictData: []
  167. }
  168. },
  169. type: {
  170. type: Number,
  171. default: 1
  172. },
  173. },
  174. created() {
  175. this.config = {}
  176. if(this.type){
  177. if(this.formConfig.tableid == -1){
  178. // console.log(-1)
  179. // console.log(this.formConfig.mask.slice(1,2))
  180. this.shoeuw = false
  181. if(this.formConfig.readonly == true){
  182. this.formConfig.disabshow = true
  183. }else if(this.formConfig.mask.slice(1,2) == '0' || this.formConfig.isonliy == true){
  184. this.formConfig.disabshow = true
  185. }else{
  186. this.formConfig.disabshow = false
  187. }
  188. if(this.formConfig.fkInfo == null){
  189. this.formConfig.fkInfo=false
  190. }
  191. }else{
  192. // console.log(0)
  193. this.shoeuw = true
  194. if(this.formConfig.readonly == true){
  195. this.formConfig.disabshow = true
  196. }else if(this.formConfig.mask.slice(3,4) == '0' || this.formConfig.isonliy == true){
  197. this.formConfig.disabshow = true
  198. }else{
  199. this.formConfig.disabshow = false
  200. }
  201. if(this.formConfig.fkInfo == null){
  202. this.formConfig.fkInfo=false
  203. }
  204. }
  205. }
  206. if(this.formConfig.tableColumnuy == null){
  207. this.ieug = null
  208. }else{
  209. this.ieug = 24 / (this.formConfig.tableColumnuy -0)
  210. }
  211. this.init()
  212. if (this.formConfig.extendedAttributes) {
  213. let extend = JSON.parse(this.formConfig.extendedAttributes)
  214. this.extFn(extend.col, extend.comp)
  215. }
  216. if(this.formConfig.htmlType == 'imageUpload' || this.formConfig.htmlType == 'fileUpload'){
  217. this.config = []
  218. if(this.formConfig.columnValue !== null && this.formConfig.columnValue !== '[]' ){
  219. this.config = JSON.parse(this.formConfig.columnValue)
  220. }
  221. }
  222. },
  223. watch: {
  224. 'config': {
  225. handler: function() {
  226. this.$emit('modelFn', this.formConfig.columnName, this.config[this.formConfig.columnName])
  227. },
  228. deep: true
  229. },
  230. 'queryData': {
  231. handler: function() {
  232. if (this.formConfig.extendedAttributes) {
  233. let extend = JSON.parse(this.formConfig.extendedAttributes)
  234. this.formConfig.extend=extend
  235. console.log(this.jueg,789)
  236. this.extFn(extend.col, extend.comp)
  237. }
  238. },
  239. deep: true
  240. },
  241. // 根据名称筛选部门树
  242. deptName(val) {
  243. console.log(this.$refs.tree)
  244. this.$refs.tree.filter(val);
  245. }
  246. },
  247. mounted() {
  248. // this.getUser()
  249. console.log(this.formConfig)
  250. },
  251. methods: {
  252. iChange(val){
  253. console.log(val,45)
  254. if(this.formConfig.isUseExtend){
  255. this.shoeuw = false
  256. this.jueg = 1
  257. // console.log( this.shoeuw)
  258. this.$emit('iChange',this.formConfig.columnName,val)
  259. }
  260. },
  261. extFn(col, comp) {
  262. // console.log(col, this.queryData.showData,comp,45)
  263. console.log(this.formConfig.tableName)
  264. let str = this.getDyn(col, this.queryData.showData,comp)
  265. console.log(str,457)
  266. this.huetge.dept_id = this.formConfig.depdid
  267. if(this.shoeuw == false){
  268. console.log(this.shoeuw)
  269. let str = this.getDyn(col, this.queryData.showData,comp)
  270. if(str !== undefined){
  271. let hue = []
  272. hue = str.split('-')
  273. this.huetge.leavefrom_end_time = str.substring(0,19)
  274. this.huetge.leavefrom_start_time = str.substring(20)
  275. listIndextime( this.huetge).then(response => {
  276. if (response.code == 200) {
  277. this.config[this.formConfig.columnName] = response.data
  278. if(this.formConfig.tableName =='boman_temp_leaveform'){
  279. // consolelog(123456)
  280. // if(){
  281. // }
  282. }
  283. }
  284. this.loading = false;
  285. })
  286. console.log(this.huetge)
  287. }
  288. }else{
  289. console.log(this.jueg)
  290. console.log(this.formConfig.columnName,12)
  291. // let str = this.getDyn(col, this.queryData.showData,comp)
  292. this.queryData.showData.filter(route => {
  293. route.hrChildren.filter(routerst => {
  294. if (routerst.columnName == 'leavefrom_start_time') {
  295. console.log(routerst.columnValue)
  296. this.huetge.leavefrom_start_time = routerst.columnValue
  297. }
  298. if(routerst.columnName == 'leavefrom_end_time'){
  299. this.huetge.leavefrom_end_time = routerst.columnValue
  300. }
  301. })
  302. })
  303. listIndextime( this.huetge).then(response => {
  304. if (response.code == 200) {
  305. this.config[this.formConfig.columnName] = response.data
  306. }
  307. this.loading = false;
  308. })
  309. }
  310. },
  311. eval(code){
  312. let fun = new Function(`return ${code}`)();
  313. return fun
  314. },
  315. listIndexfouFn() {
  316. listIndexfou(this.aliemg).then(response => {
  317. if (response.data) {
  318. this.filterList = response.data.rows
  319. console.log(this.filterList,876)
  320. }
  321. this.loading = false;
  322. })
  323. },
  324. remoteMethod(query) {
  325. if (query !== '') {
  326. this.loading = true;
  327. this.aliemg.fixedData.condition[this.formConfig.fkInfo.dkColumnName] = query
  328. this.listIndexfouFn()
  329. } else {
  330. this.filterList = [];
  331. }
  332. },
  333. upImageFn(res, file) {
  334. this.config.push(res.data);
  335. console.log(this.config)
  336. },
  337. err(){
  338. console.log(35)
  339. },
  340. init() {
  341. if (this.formConfig.htmlType == 'checkbox' || this.formConfig.htmlType == 'imageUpload' || this.formConfig.htmlType ==
  342. 'fileUpload') {
  343. this.config = []
  344. } else {
  345. this.$set(this.config, this.formConfig.columnName, ((this.formConfig.columnValue ? this.formConfig.columnValue :
  346. this.formConfig.defaultValue) || ''))
  347. }
  348. if (this.formConfig.htmlType == 'cascader'){
  349. console.log(this.formConfig.sysDictData,987)
  350. for(var i = 0 ; i< this.formConfig.sysDictData.length; i++){
  351. this.getChilds(this.formConfig.sysDictData[i])
  352. }
  353. }
  354. if (this.formConfig.fkInfo) {
  355. this.aliemg.table = this.formConfig.fkInfo.fkTableName
  356. if (this.formConfig.fkInfo.value) {
  357. this.aliemg.fixedData.condition[this.formConfig.fkInfo.dkColumnName] = this.formConfig.fkInfo.value
  358. this.formConfig.fkInfo.name = this.formConfig.fkInfo.name - 0
  359. this.formConfig.columnValue = this.formConfig.columnValue - 0
  360. console.log(this.formConfig.fkInfo.name,this.formConfig.columnValue)
  361. }
  362. this.listIndexfouFn()
  363. }
  364. },
  365. handleChange(file, fileList) {
  366. this.fileList = fileList.slice(-3);
  367. },
  368. getToken() {
  369. return getToken()
  370. },
  371. reseImage(file, fileList) {
  372. let urls = ""
  373. if (file.response) {
  374. urls = file.response.url
  375. } else {
  376. urls = file.url
  377. }
  378. for (let i = this.config.length - 1; i >= 0; i--) {
  379. if (this.config[i].url == urls) {
  380. this.config.splice(i, 1);
  381. }
  382. }
  383. },
  384. reseImage1(file, fileList) {
  385. let urls = ""
  386. if (file.response) {
  387. urls = file.response.url
  388. } else {
  389. urls = file.url
  390. }
  391. for (let i = this.config.length - 1; i >= 0; i--) {
  392. if (this.config[i].url == urls) {
  393. this.config.splice(i, 1);
  394. }
  395. }
  396. },
  397. handlePictureCardPreview(file) {
  398. console.log(file)
  399. this.dialogImageUrl = file.url;
  400. this.dialogVisible = true;
  401. },
  402. handleDownload(file) {
  403. console.log(file);
  404. },
  405. handleQuery() {
  406. this.$emit('btns')
  407. },
  408. handleCheckedCitiesChange(value) {
  409. console.log(this.config)
  410. },
  411. /** 转换组数据结构 */
  412. normalizerty(node) {
  413. return {
  414. id: node.id,
  415. label: node.groupName,
  416. };
  417. },
  418. djieskletwo(node, instanceId) {
  419. // this.members(node.id);
  420. // this.elezu = node.id
  421. console.log(node, instanceId);
  422. },
  423. // 筛选节点
  424. filterNode(value, data) {
  425. console.log(value,data)
  426. if (!value) return true;
  427. return data.label.indexOf(value) !== -1;
  428. },
  429. // 节点单击事件
  430. handleNodeClick(data) {
  431. console.log(data);
  432. // this.queryParams.deptId = data.id;
  433. // this.staff(data.id);
  434. // this.quandet = false
  435. // this.getList();
  436. },
  437. handleChangety(value,ik){
  438. // if(value.length ==1){
  439. // this.queryParams.referralList[1].sysDeptId = value.join(',')
  440. // }else{
  441. // this.queryParams.referralList[1].sysDeptId = value[value.length-1]
  442. // }
  443. //1
  444. console.log(value,ik)
  445. },
  446. getCheckedNodes(value){
  447. // console.log(value)
  448. },
  449. formateDate(datetime) {
  450. function addDateZero(num) {
  451. return (num < 10 ? "0" + num : num);
  452. }
  453. let d = new Date(datetime);
  454. let formatdatetime = d.getFullYear() + '-' + addDateZero(d.getMonth() + 1) + '-' + addDateZero(d.getDate()) + ' ' + addDateZero(d.getHours()) + ':' + addDateZero(d.getMinutes()) + ':' + addDateZero(d.getSeconds());
  455. return formatdatetime;
  456. },
  457. // 递归
  458. getChilds(data){
  459. console.log(data,67)
  460. if(data !== null){
  461. console.log(7)
  462. if(data.children.length == 0){
  463. data.children = undefined
  464. }else{
  465. for(var i = 0 ; i< data.children.length; i++){
  466. if(data.children[i].length == 0){
  467. // data.children[i] = undefined
  468. // console.log(data.children[i],8)
  469. }else{
  470. // console.log(data.children[i],9)
  471. this.getChilds(data.children[i])
  472. }
  473. // console.log(data.children[i],10)
  474. }
  475. }
  476. }
  477. // if(data.children.length == 0){
  478. // data.children = null
  479. // }else{
  480. // this.getChilds(data.children)
  481. // }
  482. },
  483. getUser() {
  484. getUserProfile().then(response => {
  485. this.huetge.dept_id = response.data.deptId;
  486. });
  487. },
  488. }
  489. }
  490. </script>
  491. <style>
  492. </style>