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.

217 lines
6.8 KiB

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