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.

251 lines
8.1 KiB

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