plm前端
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.4 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
  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<501||this.tagNo>999)">
  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. getChooselist,
  60. getChooselistData
  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. getChooselist({"tagNo": tagNo}).then(({data}) => {
  103. this.columnList = []
  104. this.baseListData = data.data
  105. let start = data.data.sqlcode.toUpperCase().indexOf("Select".toUpperCase())
  106. let end = data.data.sqlcode.toUpperCase().indexOf("from".toUpperCase())
  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. //debugger
  113. switch (index) {
  114. case 0:
  115. name = this.baseListData.caption1
  116. break;
  117. case 1:
  118. name = this.baseListData.caption2
  119. break;
  120. case 2:
  121. name = this.baseListData.caption3
  122. break;
  123. case 3:
  124. name = this.baseListData.caption4
  125. break;
  126. }
  127. let index1 = item.indexOf(" as ");
  128. let index2 = item.indexOf(".");
  129. let l = item.length
  130. let prop = item
  131. if (index1> 0){
  132. prop = item.substring(index1+3,l).trim()
  133. }
  134. if (index1<0 && index2>0){
  135. prop = item.substring(index2+1,l)
  136. }
  137. let column = {
  138. "columnProp":prop.trim(),
  139. "columnLabel": name,
  140. "columnHidden": false,
  141. "columnImage": false,
  142. "columnSortable": false,
  143. "columnWidth": null,
  144. "format": null,
  145. "sortLv": index,
  146. "status": true,
  147. "fixed": false,
  148. "serialNumber": null,
  149. "columnType": null,
  150. "align": null
  151. }
  152. this.columnList.push(column)
  153. })
  154. this.getDataList(true)
  155. })
  156. this.dataListLoading = false
  157. },
  158. getDataList(bool) {
  159. let sql = this.baseListData.sqlcode
  160. if (bool){
  161. sql += " and (" + this.baseListData.fieldname1 + " like '%" + this.param + "%' OR "+this.baseListData.fieldname2 + " like '%" + this.param + "%'" +" ) "
  162. }
  163. if (this.param1) {
  164. sql += " and " + this.baseListData.fieldname1 + " like '%" + this.param1 + "%'"
  165. }
  166. if (this.param2) {
  167. sql += " and " + this.baseListData.fieldname2 + " like '%" + this.param2 + "%'"
  168. }
  169. if (this.param3) {
  170. sql += " and active like '%" + this.param3 + "%'"
  171. }
  172. if (this.tagNo <1000 && this.tagNo !== 93){
  173. console.log(this.tagNo)
  174. if (this.param4) {
  175. sql += " and site=" + this.param4
  176. }
  177. }
  178. sql += this.conSql
  179. getChooselistData({"sqlcode": sql}).then(({data}) => {
  180. if (data.code == 0) {
  181. this.dataList = data.baseListData;
  182. } else {
  183. this.$message.error(data.msg)
  184. }
  185. })
  186. },
  187. getRowData(row) {
  188. this.visible = false
  189. this.$emit('getBaseData',row)
  190. },
  191. closeDialog(){
  192. this.param1= ''
  193. this.param2=''
  194. this.param3= ''
  195. this.param= ''
  196. this.param4=this.$store.state.user.site
  197. }
  198. }
  199. }
  200. </script>
  201. <style>
  202. </style>