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.

215 lines
6.3 KiB

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