protocolHome.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <!--
  2. * @Author: Badguy
  3. * @Date: 2022-04-12 17:49:47
  4. * @LastEditTime: 2022-04-13 16:17:37
  5. * @LastEditors: your name
  6. * @Description: 协议管理-首页
  7. * have a nice day!
  8. -->
  9. <template>
  10. <div class="protocol-home">
  11. <div class="wrap">
  12. <!-- <div class="protocol-header flex">
  13. <div class="status flex-wrap">
  14. <div class="manageTitle">协议管理</div>
  15. <div class="status1"><span class="icon"></span>内置</div>
  16. <div class="status2"><span class="icon"></span>扩展</div>
  17. </div>
  18. <div class="addBtn">
  19. <el-button class="button-white" size="small" @click="showAddDialog()">新增</el-button>
  20. </div>
  21. </div> -->
  22. <div class="protocol-content">
  23. <DataTable data-id="1" :rows="12" labelWidth="100px" :minHeight="70" width="800px" />
  24. <!-- <el-row :gutter="24">
  25. <el-col v-for="item in dataList" :key="item.protocolId" :span="4">
  26. <div class="grid-content">
  27. <div :class="item.protocolStatus=='1' ? 'success' : 'error'" class="grid-content-bg"></div>
  28. <div class="grid-content-hand flex">
  29. <div class="title flex-wrap">
  30. <el-tooltip class="item" effect="dark" :content="item.protocolName" placement="bottom">
  31. <div class="name">{{ item.protocolName }}</div>
  32. </el-tooltip>
  33. <i class="loger" @click="showEditDialog(item)" />
  34. </div>
  35. <i class="el-icon-close icon" @click="showRemoveDialog(item)" />
  36. </div>
  37. </div>
  38. </el-col>
  39. </el-row> -->
  40. </div>
  41. <!--新增/编辑-->
  42. <Dialog :flag="editDialogVisible" width="508px" :show-flag="true">
  43. <div class="airportInfoDialog dialog-public-background">
  44. <div class="title">{{ editDialogTitle }}</div>
  45. <div class="content">
  46. <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
  47. <el-form-item label="协议名称" prop="protocolName">
  48. <el-input v-model="ruleForm.protocolName" size="medium" placeholder="请输入协议名称(必填)" />
  49. </el-form-item>
  50. <el-form-item label="协议类型" prop="nodeType">
  51. <el-select v-model="ruleForm.nodeType" size="small" placeholder="请选择协议类型">
  52. <el-option label="内置" value="1"></el-option>
  53. <el-option label="扩展" value="2"></el-option>
  54. </el-select>
  55. </el-form-item>
  56. <el-form-item label="类名" prop="className">
  57. <el-input v-model="ruleForm.className" size="medium" type="textarea" :rows="2" placeholder="请输入类名(必填)" />
  58. </el-form-item>
  59. <el-form-item label="读方法名" prop="rmethodName">
  60. <el-input v-model="ruleForm.rmethodName" size="medium" placeholder="请输入读方法名(必填)" />
  61. </el-form-item>
  62. <el-form-item label="写方法名" prop="smethodName">
  63. <el-input v-model="ruleForm.smethodName" size="medium" placeholder="请输入写方法名(必填)" />
  64. </el-form-item>
  65. <el-form-item label="文件名及路径" prop="filePath">
  66. <el-input v-model="ruleForm.filePath" size="medium" type="textarea" :rows="3" placeholder="请输入文件名及路径" />
  67. </el-form-item>
  68. </el-form>
  69. </div>
  70. <div class="foot center t30">
  71. <el-button size="medium" type="primary" class="r25 r26" @click="submitClickHandler()">提交</el-button>
  72. <el-button size="medium" class="r26" @click="resetForm('ruleForm')">取消</el-button>
  73. </div>
  74. </div>
  75. </Dialog>
  76. <!--删除弹框-->
  77. <Dialog :flag="removeDialogVisible">
  78. <div class="airportInfoDialog">
  79. <div class="del-title">删除协议</div>
  80. <div class="content er">
  81. <div class="log">
  82. 是否确认删除{{ rmObj.protocolName }}?
  83. </div>
  84. </div>
  85. <div class="DelFoot right t30">
  86. <el-button size="medium" class="r25 r26" type="danger" @click="removeSubmit()">删除</el-button>
  87. <el-button size="medium" class="r26" @click="removeDialogVisible = false">取消</el-button>
  88. </div>
  89. </div>
  90. </Dialog>
  91. </div>
  92. </div>
  93. </template>
  94. <script>
  95. import Dialog from '@/layout/components/Dialog/index.vue'
  96. import { GeneralDataReception, Query } from '@/api/dataIntegration'
  97. import DataTable from '@/components/Table'
  98. export default {
  99. name: 'ProtocolHome',
  100. components: { Dialog, DataTable },
  101. data () {
  102. return {
  103. dataList: [],
  104. editDialogVisible: false,
  105. removeDialogVisible: false,
  106. rmObj: {},
  107. editDialogTitle: '新增协议',
  108. ruleForm: {
  109. // 协议信息表单
  110. protocolName: '',
  111. className: '',
  112. rmethodName: '',
  113. smethodName: '',
  114. filePath: ''
  115. },
  116. rules: {
  117. // 协议信息表单验证
  118. protocolName: [{ required: true, message: '请输入协议名称', trigger: 'blur' }],
  119. className: [{ required: true, message: '请输入类名', trigger: 'blur' }],
  120. rmethodName: [{ required: true, message: '请输入读方法名', trigger: 'blur' }],
  121. smethodName: [{ required: true, message: '请输入写方法名', trigger: 'blur' }]
  122. }
  123. }
  124. },
  125. created () {
  126. //this.getList()
  127. },
  128. methods: {
  129. async getList () {
  130. try {
  131. const res = await Query({
  132. id: 1,
  133. dataContent: []
  134. });
  135. if (res.code === "0") {
  136. this.dataList = res.returnData;
  137. } else {
  138. this.$message.error(res.message ?? "失败");
  139. }
  140. } catch (error) {
  141. console.log("错误", error);
  142. }
  143. },
  144. // 新增-弹框
  145. showAddDialog () {
  146. this.editDialogTitle = '新增协议'
  147. this.editDialogVisible = true
  148. },
  149. // 编辑-弹框
  150. showEditDialog (item) {
  151. this.editDialogTitle = '编辑协议'
  152. this.ruleForm = item
  153. this.editDialogVisible = true
  154. },
  155. // 新增/编辑-确认
  156. submitClickHandler () {
  157. this.$refs['ruleForm'].validate(valid => {
  158. if (valid) {
  159. if (!this.ruleForm.protocolId) {
  160. this.addSubmit()
  161. } else {
  162. this.editSubmit()
  163. }
  164. this.resetForm('ruleForm')
  165. }
  166. })
  167. },
  168. // 重置
  169. resetForm (formName) {
  170. this.ruleForm = {};
  171. this.$refs[formName].resetFields()
  172. this.editDialogVisible = false
  173. },
  174. // 删除-弹框
  175. showRemoveDialog (item) {
  176. this.rmObj = item
  177. this.removeDialogVisible = true
  178. },
  179. // 确认删除
  180. async removeSubmit () {
  181. this.rmObj["operate"] = "3";
  182. try {
  183. const res = await GeneralDataReception({
  184. serviceId: "1",
  185. dataContent: JSON.stringify(this.rmObj),
  186. });
  187. if (res.code === "0") {
  188. this.removeDialogVisible = false;
  189. this.$message.success("删除成功");
  190. this.getList()
  191. } else {
  192. this.$message.error(res.message ?? "失败");
  193. }
  194. } catch (error) {
  195. console.log("错误", error);
  196. }
  197. },
  198. async addSubmit () {
  199. this.ruleForm["operate"] = "1";
  200. try {
  201. const res = await GeneralDataReception({
  202. serviceId: '1',
  203. dataContent: JSON.stringify(this.ruleForm)
  204. })
  205. if (res.code === "0") {
  206. this.$message.success(res.message ?? '成功')
  207. this.getList()
  208. } else {
  209. this.$message.error(res.message ?? '失败')
  210. }
  211. } catch (error) {
  212. console.log('错误', error)
  213. }
  214. },
  215. async editSubmit () {
  216. this.ruleForm["operate"] = "2";
  217. try {
  218. const res = await GeneralDataReception({
  219. serviceId: '1',
  220. dataContent: JSON.stringify(this.ruleForm)
  221. })
  222. if (res.code === "0") {
  223. this.$message.success(res.message ?? '成功')
  224. this.getList()
  225. } else {
  226. this.$message.error(res.message ?? '失败')
  227. }
  228. } catch (error) {
  229. console.log('错误', error)
  230. }
  231. }
  232. }
  233. }
  234. </script>
  235. <style lang="scss" scoped>
  236. .protocol-home {
  237. .wrap {
  238. padding: 16px 0;
  239. .protocol-header {
  240. line-height: 32px;
  241. font-size: 14px;
  242. .button-white {
  243. border: 1px solid #9ebbf7;
  244. background: #f5f7fa;
  245. -webkit-box-shadow: 0px 6px 7px 0px rgb(0 0 0 / 6%);
  246. box-shadow: 0px 6px 7px 0px rgb(0 0 0 / 6%);
  247. border-radius: 4px;
  248. font-family: Microsoft YaHei;
  249. font-weight: bold;
  250. color: #2d67e3;
  251. }
  252. margin-bottom: 30px;
  253. .status {
  254. & > div {
  255. .icon {
  256. width: 14px;
  257. height: 14px;
  258. background: #2d67e3;
  259. border-radius: 2px;
  260. display: inline-block;
  261. vertical-align: middle;
  262. margin-right: 10px;
  263. position: relative;
  264. top: -2px;
  265. }
  266. &:last-child {
  267. margin-right: 0;
  268. }
  269. }
  270. .status1 {
  271. font-size: 14px;
  272. margin-right: 28px;
  273. }
  274. .status2 {
  275. font-size: 14px;
  276. .icon {
  277. background: #f4c154;
  278. }
  279. }
  280. }
  281. }
  282. .protocol-content {
  283. .grid-content {
  284. height: 120px;
  285. background: #ffffff;
  286. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.1);
  287. border-radius: 4px;
  288. padding: 25px;
  289. margin-bottom: 24px;
  290. position: relative;
  291. .grid-content-bg {
  292. position: absolute;
  293. width: 100%;
  294. height: 4px;
  295. background-color: #f4c154;
  296. top: 0;
  297. left: 0;
  298. border-radius: 4px 4px 0 0;
  299. }
  300. .title {
  301. font-size: 16px;
  302. font-family: Helvetica;
  303. font-weight: bold;
  304. color: #101116;
  305. white-space: nowrap;
  306. max-width: 80%;
  307. text-overflow: ellipsis;
  308. overflow: hidden;
  309. .name {
  310. white-space: nowrap;
  311. max-width: 80%;
  312. text-overflow: ellipsis;
  313. overflow: hidden;
  314. }
  315. .loger {
  316. width: 14px;
  317. height: 14px;
  318. margin-left: 24px;
  319. background: url("../../../../assets/status/ic_edit_default.png")
  320. no-repeat;
  321. background-size: 100% 100%;
  322. cursor: pointer;
  323. position: relative;
  324. top: 2px;
  325. }
  326. .loger:hover {
  327. background: url("../../../../assets/status/ic_edit_hovar.png")
  328. no-repeat;
  329. background-size: 100% 100%;
  330. }
  331. }
  332. .icon {
  333. cursor: pointer;
  334. font-size: 16px;
  335. color: #606266;
  336. }
  337. .success {
  338. background-color: #2d67e3;
  339. }
  340. .error {
  341. background-color: #f4c154;
  342. }
  343. }
  344. }
  345. .r25 {
  346. color: #ffffff;
  347. }
  348. }
  349. }
  350. </style>