赫艾前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

274 lines
8.7 KiB

  1. <template>
  2. <el-dialog class="yzzInput" :title="baseListData.description" append-to-body :close-on-click-modal="false" :close-on-press-escape="false" @close="closeDialog" :visible.sync="visible" width="685px" v-drag>
  3. <el-form label-position="top" inline="inline" size="mini" >
  4. <el-row :gutter="10">
  5. <el-col :span="6" >
  6. <el-form-item :label="baseListData.caption1" v-if="baseListData.caption1 != '' && baseListData.caption1 != null">
  7. <el-input v-model="param1"></el-input>
  8. </el-form-item>
  9. </el-col>
  10. <el-col :span="6" >
  11. <el-form-item :label="baseListData.caption2" v-if="baseListData.caption2 != '' && baseListData.caption2 != null">
  12. <el-input v-model="param2"></el-input>
  13. </el-form-item>
  14. </el-col>
  15. <el-col :span="6" >
  16. <el-form-item :label="baseListData.caption3" v-if="baseListData.caption3 != '' && baseListData.caption3 != null">
  17. <el-input v-model="param3"></el-input>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :span="6" >
  21. <el-form-item :label="baseListData.caption4" v-if="baseListData.caption4 != '' && baseListData.caption4 != null">
  22. <el-input v-model="param4"></el-input>
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="6" >
  26. <el-form-item :label="baseListData.caption5" v-if="baseListData.caption5 != '' && baseListData.caption5 != null">
  27. <el-input v-model="param5"></el-input>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="6" >
  31. <el-form-item :label="baseListData.caption6" v-if="baseListData.caption6 != '' && baseListData.caption6 != null ">
  32. <el-select v-model="param6" style="width: 120px">
  33. <el-option label="全部" value=""></el-option>
  34. <el-option label="在用" value="Y"></el-option>
  35. <el-option label="不在用" value="N"></el-option>
  36. </el-select>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="6" >
  40. <el-form-item :label="baseListData.caption7" v-if="baseListData.caption7 != '' && baseListData.caption7 != null">
  41. <el-input v-model="param7"></el-input>
  42. </el-form-item>
  43. </el-col>
  44. <el-col :span="6" >
  45. <el-button style="margin-top: 18px" type="primary" @click="getDataList(false)">查询
  46. </el-button>
  47. </el-col>
  48. </el-row>
  49. </el-form>
  50. <el-table
  51. :height="height"
  52. :data="dataList"
  53. border
  54. @row-dblclick="getRowData"
  55. v-loading="dataListLoading"
  56. style="width: 100%;">
  57. <el-table-column
  58. v-for="(item,index) in columnList" :key="index"
  59. :sortable="item.columnSortable"
  60. :prop="item.columnProp"
  61. :header-align="item.headerAlign"
  62. :show-overflow-tooltip="item.showOverflowTooltip"
  63. :align="item.align"
  64. :fixed="item.fixed==''?false:item.fixed"
  65. :min-width="item.columnWidth"
  66. :label="item.columnLabel">
  67. <template slot-scope="scope">
  68. {{ scope.row[item.columnProp] }}
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. <span slot="footer" class="dialog-footer">
  73. <el-button @click="visible = false" type="primary">关闭</el-button>
  74. </span>
  75. </el-dialog>
  76. </template>
  77. <script>
  78. import {
  79. getChooselistEam,
  80. getChooselistDataEam,
  81. } from "@/api/chooselist/chooselist.js"
  82. export default {
  83. data() {
  84. return {
  85. height: 200,
  86. tagNo: '',
  87. title: '列表',
  88. columnList: [],
  89. queryTable: {},
  90. visible: false,
  91. dataListLoading: true,
  92. fullscreenLoading: false,
  93. param1: '',
  94. param2: '',
  95. param3: '',
  96. param4: '',
  97. param5: '',
  98. param6: '',
  99. param7: this.$store.state.user.name,
  100. param: '',
  101. conSql: '',
  102. dataList: [],
  103. baseListData: {
  104. caption1: '',
  105. caption2: '',
  106. caption3: '',
  107. caption4: '',
  108. caption5: '',
  109. caption6: '',
  110. caption7: '',
  111. description: '',
  112. fieldname1: '',
  113. fieldname2: '',
  114. fieldname3: '',
  115. fieldname4: '',
  116. fieldname5: '',
  117. fieldname6: '',
  118. sqlcode: '',
  119. tagno: '',
  120. },
  121. defaultParam: false
  122. }
  123. },
  124. methods: {
  125. // 获取 用户的配置
  126. init (tagNo, param, conSql) {
  127. this.tagNo = tagNo
  128. this.visible = true
  129. this.param = param
  130. this.conSql = conSql ? conSql : ''
  131. // 根据 tagNo 获取列表
  132. getChooselistEam({"tagNo": tagNo}).then(({data}) => {
  133. this.columnList = []
  134. this.baseListData = data.data
  135. let start = data.data.sqlcode.toUpperCase().indexOf("Select".toUpperCase())
  136. let end = data.data.sqlcode.toUpperCase().indexOf("from".toUpperCase())
  137. let length = end - start
  138. let columns = data.data.sqlcode.trim().substring(start + 6, length).trim()
  139. let props = columns.split(",")
  140. props.forEach((item, index) => {
  141. let name = '信息列'
  142. switch (index) {
  143. case 0:
  144. name = this.baseListData.caption1
  145. break;
  146. case 1:
  147. name = this.baseListData.caption2
  148. break;
  149. case 2:
  150. name = this.baseListData.caption3
  151. break;
  152. case 3:
  153. name = this.baseListData.caption4
  154. break;
  155. case 4:
  156. name = this.baseListData.caption5
  157. break;
  158. case 5:
  159. name = this.baseListData.caption6
  160. break;
  161. case 6:
  162. name = this.baseListData.caption7
  163. break;
  164. }
  165. let index1 = item.indexOf(" as ")
  166. let index2 = item.indexOf(".")
  167. let l = item.length
  168. let prop = item
  169. if (index1 > 0) {
  170. prop = item.substring(index1 + 3, l).trim()
  171. }
  172. if (index1 < 0 && index2 > 0) {
  173. prop = item.substring(index2 + 1, l)
  174. }
  175. let column = {
  176. "columnProp": prop.trim(),
  177. "columnLabel": name,
  178. "columnHidden": false,
  179. "columnImage": false,
  180. "columnSortable": false,
  181. "columnWidth": null,
  182. "format": null,
  183. "sortLv": index,
  184. "status": true,
  185. "fixed": false,
  186. "serialNumber": null,
  187. "columnType": null,
  188. "align": null
  189. }
  190. this.columnList.push(column)
  191. })
  192. this.getDataList(true)
  193. })
  194. this.dataListLoading = false
  195. },
  196. getDataList (bool) {
  197. let sql = this.baseListData.sqlcode
  198. if (bool) {
  199. sql += " and (" + this.baseListData.fieldname1 + " like '%" + this.param + "%' OR " + this.baseListData.fieldname2 + " like '%" + this.param + "%'" + " ) "
  200. }
  201. if (this.param1) {
  202. sql += " and " + this.baseListData.fieldname1 + " like '%" + this.param1 + "%'"
  203. }
  204. if (this.param2) {
  205. sql += " and " + this.baseListData.fieldname2 + " like '%" + this.param2 + "%'"
  206. }
  207. if (this.param3) {
  208. sql += " and " + this.baseListData.fieldname3 + " like '%" + this.param3 + "%'"
  209. }
  210. if (this.param4) {
  211. sql += " and " + this.baseListData.fieldname4 + " like '%" + this.param4 + "%'"
  212. }
  213. if (this.param5) {
  214. sql += " and " + this.baseListData.fieldname5 + " like '%" + this.param5 + "%'"
  215. }
  216. if (this.param6 ) {
  217. sql += " and active like '%" + this.param6 + "%'"
  218. }
  219. if (this.tagNo == 1042) {
  220. sql += " and site = '" + this.$store.state.user.site + "' "
  221. }
  222. // if (this.tagNo <= 500 && this.tagNo !== 93 && this.tagNo !== 201) {
  223. // if (this.param7) {
  224. // sql += " and site in (select site from eam_access_site where username = '" + this.param7 + "') " + " and (site + '-' + bu_no) in (select (a.site + '-' + a.bu_no) from AccessBu as a left join eam_access_site as b on a.site = b.site and a.username = b.username where a.username = '" + this.param7 + "')"
  225. // }
  226. // }
  227. // if (this.tagNo > 500 && this.tagNo < 1000) {
  228. // if (this.param7) {
  229. // sql += " and site in (select site from eam_access_site where username = '" + this.param7 + "') "
  230. // }
  231. // }
  232. sql += this.conSql
  233. getChooselistDataEam({"sqlcode": sql}).then(({data}) => {
  234. if (data.code == 0) {
  235. this.dataList = data.baseListData;
  236. } else {
  237. this.$message.error(data.msg)
  238. }
  239. })
  240. },
  241. getRowData (row) {
  242. this.visible = false
  243. this.$emit('getBaseData',row)
  244. },
  245. closeDialog () {
  246. this.param1 = ''
  247. this.param2 = ''
  248. this.param3 = ''
  249. this.param4 = ''
  250. this.param5 = ''
  251. this.param6 = ''
  252. this.param7 = this.$store.state.user.name
  253. this.param = ''
  254. this.dataList = []
  255. }
  256. }
  257. }
  258. </script>
  259. <style>
  260. </style>