冷凝胶前端
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.

287 lines
8.4 KiB

2 years ago
  1. <template>
  2. <div class="mod-config">
  3. <el-form label-position="top" style="margin-top: 1px; margin-left: 0px;">
  4. <el-form :inline="true" label-position="top" style="margin-top: 0px">
  5. <el-button type="primary" @click="searchTable()">查询</el-button>
  6. <download-excel
  7. :fields="fields()"
  8. :data="exportData"
  9. type="xls"
  10. :name="exportName"
  11. :header="exportHeader"
  12. :footer="exportFooter"
  13. :fetch="createExportData"
  14. :before-generate="startDownload"
  15. :before-finish="finishDownload"
  16. worksheet="导出信息"
  17. class="el-button el-button--primary el-button--medium">
  18. {{ '导出' }}
  19. </download-excel>
  20. </el-form>
  21. </el-form>
  22. <el-table
  23. :data="dataList"
  24. :height="height"
  25. border
  26. v-loading="dataListLoading"
  27. style="width: 100%; ">
  28. <el-table-column
  29. v-for="(item,index) in columnList1" :key="index"
  30. :sortable="item.columnSortable"
  31. :prop="item.columnProp"
  32. :header-align="item.headerAlign"
  33. :show-overflow-tooltip="item.showOverflowTooltip"
  34. :align="item.align"
  35. :fixed="item.fixed==''?false:item.fixed"
  36. :min-width="item.columnWidth"
  37. :label="item.columnLabel">
  38. <template slot-scope="scope">
  39. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  40. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  41. style="width: 100px; height: 80px"/></span>
  42. </template>
  43. </el-table-column>
  44. <el-table-column
  45. header-align="center"
  46. align="center"
  47. width="150"
  48. fixed="right"
  49. label="操作">
  50. <template slot-scope="scope">
  51. <a type="text" size="small" @click="fieldModel(scope.row)">查看字段</a>
  52. </template>
  53. </el-table-column>
  54. </el-table>
  55. <el-dialog
  56. width="600px"
  57. title="字段明细"
  58. :close-on-click-modal="false"
  59. :visible.sync="modelFlag">
  60. <el-form label-position="top" style="margin-top: 1px; margin-left: 0px;">
  61. 功能名称 <el-input v-model="rowData.functionName" style="width: 130px" readonly></el-input>
  62. </el-form>
  63. <el-table
  64. height="300"
  65. :data="fieldList"
  66. border
  67. style="width: 100%">
  68. <el-table-column
  69. prop="fieldName"
  70. header-align="center"
  71. align="left"
  72. min-width="80"
  73. label="字段名">
  74. </el-table-column>
  75. <el-table-column
  76. prop="fieldDesc"
  77. header-align="center"
  78. align="left"
  79. min-width="100"
  80. label="字段描述">
  81. </el-table-column>
  82. <el-table-column
  83. prop=""
  84. header-align="center"
  85. align="center"
  86. width="60"
  87. label="操作">
  88. <template slot-scope="scope" class="foo_container">
  89. <a type="text" size="small" @click="accessModel(scope.row)">授权</a>
  90. </template>
  91. </el-table-column>
  92. </el-table>
  93. <span slot="footer" class="dialog-footer">
  94. <el-button type="primary" @click="modelFlag = false">关闭</el-button>
  95. </span>
  96. </el-dialog>
  97. <el-dialog
  98. style="font-size: 12px"
  99. v-drag
  100. :title="'字段授权'"
  101. :visible.sync="accessModelFlag"
  102. width="518px"
  103. :append-to-body="true">
  104. <el-transfer v-model="accessFieldList" class="rq" filterable :props="{
  105. key: 'username',
  106. label: 'userDisplay'
  107. }" :data="userList" :titles="['未选择', '已选择']"></el-transfer>
  108. <span slot="footer" class="dialog-footer">
  109. <div style="margin-top: 5px">
  110. <el-button type="primary" @click="saveAccessFieldListForField()">确定</el-button>
  111. <el-button @click="accessModelFlag = false" type="primary">取消</el-button>
  112. </div>
  113. </span>
  114. </el-dialog>
  115. </div>
  116. </template>
  117. <script>
  118. import {
  119. searchFieldFunctionList,
  120. searchFieldListWithFunction,
  121. searchAccessFieldListForField,
  122. saveAccessFieldForField,
  123. } from "@/api/base/field.js"
  124. export default {
  125. components: {
  126. },
  127. data() {
  128. return {
  129. height:200,
  130. dataList: [],
  131. dataListLoading: false,
  132. currentRow:'',
  133. columnList1:[
  134. {
  135. userId: this.$store.state.user.name,
  136. functionId: 998006,
  137. serialNumber: '998006Table1FunctionName',
  138. tableId: "998006Table1",
  139. tableName: "项目物料",
  140. columnProp: "functionName",
  141. headerAlign: "center",
  142. align: "left",
  143. columnLabel: "功能名称",
  144. columnHidden: false,
  145. columnImage: false,
  146. columnSortable: false,
  147. sortLv: 0,
  148. status: true,
  149. fixed: '',
  150. columnWidth: 80
  151. },{
  152. userId: this.$store.state.user.name,
  153. functionId: 998006,
  154. serialNumber: '998006Table1FunctionGroup',
  155. tableId: "998006Table1",
  156. tableName: "功能分组",
  157. columnProp: "functionGroup",
  158. headerAlign: "center",
  159. align: "left",
  160. columnLabel: "功能分组",
  161. columnHidden: false,
  162. columnImage: false,
  163. columnSortable: false,
  164. sortLv: 0,
  165. status: true,
  166. fixed: '',
  167. columnWidth: 80
  168. },
  169. ],
  170. rowData:{
  171. functionId:'',
  172. functionName:'',
  173. },
  174. // 导出 start
  175. exportData: [],
  176. exportName: '功能清单'+this.dayjs().format('YYYYMMDDHHmmss'),
  177. exportHeader: ["功能清单"],
  178. exportFooter: [],
  179. // 导出 end
  180. modelFlag:false,
  181. accessModelFlag:false,
  182. fieldList:[],
  183. rowFieldId:'',
  184. accessFieldList:[],
  185. userList:[],
  186. }
  187. },
  188. mounted() {
  189. this.$nextTick(() => {
  190. this.height = window.innerHeight - 140;
  191. })
  192. this.searchTable()
  193. },
  194. methods: {
  195. searchTable(){
  196. searchFieldFunctionList().then(({data}) => {
  197. //区分请求成功和失败的状况
  198. if (data && data.code == 0) {
  199. this.dataList = data.rows;
  200. } else {
  201. this.dataList = [];
  202. }
  203. });
  204. },
  205. fieldModel(row){
  206. this.rowData.functionId=row.functionId;
  207. this.rowData.functionName=row.functionName;
  208. searchFieldListWithFunction(this.rowData).then(({data}) => {
  209. //区分请求成功和失败的状况
  210. if (data && data.code == 0) {
  211. this.fieldList = data.rows;
  212. } else {
  213. this.fieldList = [];
  214. }
  215. });
  216. this.modelFlag=true;
  217. },
  218. accessModel(row){
  219. this.rowFieldId=row.fieldId
  220. searchAccessFieldListForField({fieldId:row.fieldId,
  221. }).then(({data}) => {
  222. this.accessFieldList = data.accessFieldList
  223. this.userList=data.userList
  224. })
  225. this.accessModelFlag=true
  226. },
  227. saveAccessFieldListForField(){
  228. let inList=[];
  229. for (let i = 0; i < this.accessFieldList.length; i++) {
  230. let inData={
  231. username:this.accessFieldList[i],
  232. fieldId:this.rowFieldId
  233. }
  234. inList.push(inData)
  235. }
  236. let saveData={
  237. fieldId:this.rowFieldId,
  238. accessFieldList:inList,
  239. }
  240. saveAccessFieldForField(saveData).then(({data}) => {
  241. if (data && data.code === 0) {
  242. this.$message.success( '操作成功')
  243. this.accessModelFlag = false
  244. } else {
  245. this.$message.error(data.msg)
  246. }
  247. })
  248. },
  249. //导出excel
  250. async createExportData() {
  251. return this.dataList;
  252. },
  253. startDownload() {
  254. // this.exportData = this.dataList
  255. },
  256. finishDownload() {
  257. },
  258. fields() {
  259. let json = "{"
  260. this.columnList1.forEach((item, index) => {
  261. if (index == this.columnList1.length - 1) {
  262. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
  263. } else {
  264. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
  265. }
  266. })
  267. json += "}"
  268. let s = eval("(" + json + ")")
  269. return s
  270. },
  271. },
  272. }
  273. </script>
  274. <style scoped>
  275. </style>