SipConfigs.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <script>
  2. import handle from "@/until/handle";
  3. import syncChannelProgress from "@components/dialog/SyncChannelProgress.vue";
  4. import BindDevice from "@components/account_com/bindDevice.vue";
  5. import SipConfigEdit from "@components/com/sipConfigEdit.vue";
  6. export default {
  7. name: "sipConfigs",
  8. components: {SipConfigEdit, BindDevice, syncChannelProgress},
  9. data() {
  10. return {
  11. configs: [],
  12. loading: false,
  13. total: 0,
  14. page: 1,
  15. limit: 10,
  16. showAddConfig: false,
  17. editConfig: {
  18. id: null,
  19. sipDomain: "",
  20. serverId: "",
  21. password: "",
  22. description: "",
  23. enable: "",
  24. enableBind: "",
  25. }
  26. }
  27. },
  28. beforeMount() {
  29. this.loadConfigs();
  30. },
  31. methods: {
  32. async loadConfigs() {
  33. this.loading = true;
  34. let url = "/api/sip/search"
  35. let [err, res] = await handle(
  36. this.$axios.get(url)
  37. )
  38. this.loading = false;
  39. if (err || res.data.code != 0) {
  40. let errStr = err ? err.message : res.data.msg
  41. console.log(`[搜索sip配置表] ${errStr}`)
  42. this.$message.error("加载配置失败");
  43. return;
  44. }
  45. // 加载完成
  46. let response = res.data;
  47. this.configs = response.data;
  48. this.total = response.total;
  49. },
  50. handleCurrentChange: function (val) {
  51. this.currentPage = val;
  52. this.loadConfigs();
  53. },
  54. handleSizeChange: function (val) {
  55. this.count = val;
  56. this.loadConfigs();
  57. },
  58. refreshLoad() {
  59. this.loadConfigs()
  60. },
  61. async executeDeleteConfig(id) {
  62. if (!id) {
  63. console.log(`删除sip配置时出现 id 为空的情况`)
  64. return
  65. }
  66. let url = `/api/sip/del?id=${id}`
  67. this.loading = true;
  68. let [err, res] = await handle(
  69. this.$axios.post(url)
  70. )
  71. this.loading = false;
  72. if (err || res.data.code != 0) {
  73. let errStr = err ? err.message : res.data.msg
  74. console.log(`[搜索sip配置表] ${errStr}`)
  75. this.$message.error("加载配置失败");
  76. return;
  77. }
  78. // 加载完成
  79. let response = res.data;
  80. this.configs = response.data;
  81. this.total = response.total;
  82. },
  83. copyAtCmd(row) {
  84. // 生成可用的AT命令
  85. let atCmd = "AT+CAMPARA=27, "
  86. // at+campara=27,"3402000000","34020000001320000242","34020000001320000001","12345678"
  87. atCmd += `"${row.sipDomain}",`
  88. atCmd += `"设备id",`
  89. atCmd += `"${row.serverId}",`
  90. atCmd += `"${row.password}",`
  91. },
  92. /**
  93. * 开启新增配置弹窗
  94. */
  95. handleOpenAddConfig() {
  96. this.executeOpenConfigPop();
  97. },
  98. /** 开启编辑弹窗 */
  99. handleOpenEditConfig(item) {
  100. this.editConfig = {...item}
  101. console.log(this.editConfig)
  102. this.executeOpenConfigPop();
  103. },
  104. handleDeleteConfig(item) {
  105. executeDeleteConfig(item.id);
  106. },
  107. executeOpenConfigPop() {
  108. this.showAddConfig = true;
  109. },
  110. /** 关闭配置弹窗 */
  111. executeCloseConfigPop() {
  112. this.showAddConfig = false;
  113. this.editConfig = {};
  114. this.loadConfigs();
  115. },
  116. }
  117. }
  118. </script>
  119. <template>
  120. <div class="content device-full">
  121. <!-- 设备表格 -->
  122. <!--设备列表-->
  123. <div class="round-box search-header">
  124. <div class="search-info">
  125. <div class="page-title">sip配置中心</div>
  126. <div class="page-header-btn">
  127. <el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;"
  128. type="primary"
  129. :loading="loading"
  130. @click="handleOpenAddConfig">创建新配置
  131. </el-button>
  132. <!-- <el-button icon="el-icon-refresh-right" circle size="mini" :loading="getDeviceListLoading"-->
  133. <!-- @click="getDeviceList()"></el-button>-->
  134. <el-button icon="el-icon-refresh-right" circle size="mini" :loading="loading"
  135. @click="refreshLoad()"></el-button>
  136. </div>
  137. </div>
  138. </div>
  139. <div class="round-box search-ctx mt-2" v-if="total > 0 || loading">
  140. <el-table class="search-list" :loading="loading" :data="configs" :height="'100%'"
  141. header-row-class-name="table-header">
  142. <el-table-column prop="id" label="id" min-width="30">
  143. </el-table-column>
  144. <el-table-column prop="sipDomain" label="国标域" min-width="80">
  145. </el-table-column>
  146. <el-table-column prop="serverId" label="服务端id" min-width="120">
  147. </el-table-column>
  148. <el-table-column prop="password" label="连接密码" min-width="80">
  149. </el-table-column>
  150. <el-table-column label="是否启用" min-width="80">
  151. <template slot-scope="scope">
  152. <div slot="enable" class="name-wrapper">
  153. <el-tag size="medium" v-if="scope.row.enable == 1">启用</el-tag>
  154. <el-tag size="medium" type="info" v-if="scope.row.enable == 0">不启用</el-tag>
  155. </div>
  156. </template>
  157. </el-table-column>
  158. <el-table-column label="是否为绑定设备" min-width="80">
  159. <template slot-scope="scope">
  160. <div slot="enableBind" class="name-wrapper">
  161. <el-tag size="medium" v-if="scope.row.enableBind == 1">绑定</el-tag>
  162. <el-tag size="medium" type="info" v-if="scope.row.enableBind == 0">不绑定</el-tag>
  163. </div>
  164. </template>
  165. </el-table-column>
  166. <el-table-column prop="description" label="备注" min-width="160">
  167. </el-table-column>
  168. <el-table-column label="操作" min-width="140" fixed="right">
  169. <template slot-scope="scope">
  170. <el-button size="medium" icon="el-icon-edit" type="text" @click="handleOpenEditConfig(scope.row)">编辑
  171. </el-button>
  172. <el-divider direction="vertical"></el-divider>
  173. <el-button size="medium" icon="el-icon-delete" type="text" @click="handleDeleteConfig(scope.row)"
  174. style="color: #f56c6c">删除
  175. </el-button>
  176. </template>
  177. </el-table-column>
  178. </el-table>
  179. <el-pagination
  180. style="float: right"
  181. @size-change="handleSizeChange"
  182. @current-change="handleCurrentChange"
  183. :current-page="page"
  184. :page-size="limit"
  185. :page-sizes="[10, 15, 20, 30, 50]"
  186. layout="total, sizes, prev, pager, next"
  187. :total="total">
  188. </el-pagination>
  189. </div>
  190. <!-- 没有设备提示 -->
  191. <div class="round-box search-ctx mt-2 " v-else>
  192. <div class="search-tips">
  193. <h1>无法找到对应的国标配置</h1>
  194. <div class="btn-group">
  195. <el-button @click="refreshLoad">重新加载</el-button>
  196. <el-button @click="handleOpenAddConfig()">新增国标配置</el-button>
  197. </div>
  198. </div>
  199. </div>
  200. <!-- 绑定新设备-->
  201. <el-dialog
  202. :title="editConfig.id!=null?'编辑配置':'新增配置'"
  203. :close-on-click-modal="false"
  204. :visible.sync="showAddConfig"
  205. :destroy-on-close="true"
  206. @close="executeCloseConfigPop"
  207. >
  208. <sip-config-edit
  209. :config="editConfig"
  210. @exitPop="executeCloseConfigPop"
  211. ></sip-config-edit>
  212. </el-dialog>
  213. </div>
  214. </template>
  215. <style scoped>
  216. .content {
  217. width: 100%;
  218. min-height: 100%;
  219. position: relative;
  220. /*top: 110px;*/
  221. box-sizing: border-box;
  222. padding: 5px;
  223. background-color: #a4a4a4;
  224. }
  225. .round-box {
  226. box-sizing: border-box;
  227. padding: 5px;
  228. background-color: #fff;
  229. border-radius: 3px;
  230. }
  231. .mt-2 {
  232. margin-top: 5px;
  233. }
  234. .device-full {
  235. display: flex;
  236. flex-direction: column;
  237. height: calc(100vh - 70px);
  238. }
  239. .search-info {
  240. display: flex;
  241. align-items: center;
  242. justify-content: space-between;
  243. height: 35px;
  244. }
  245. .search-ctx {
  246. width: 100%;
  247. height: calc(100% - 50px);
  248. display: flex;
  249. flex-direction: column;
  250. }
  251. .search-list {
  252. width: 100%;
  253. height: calc(100% - 50px);
  254. }
  255. .search-tips {
  256. width: 100%;
  257. height: 100%;
  258. display: flex;
  259. justify-content: center;
  260. align-items: center;
  261. flex-direction: column;
  262. }
  263. </style>