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.

247 lines
7.5 KiB

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