index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px">
  4. <el-form-item label="扫描仪名称" prop="scannerName">
  5. <el-input
  6. v-model="queryParams.scannerName"
  7. placeholder="请输入扫描仪名称"
  8. clearable
  9. @keyup.enter="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="扫描仪IP" prop="scannerIp">
  13. <el-input v-model="queryParams.scannerIp" placeholder="请输入扫描仪IP" clearable @keyup.enter="handleQuery" />
  14. </el-form-item>
  15. <el-form-item label="是否公用" prop="isPublic">
  16. <el-select v-model="queryParams.isPublic" placeholder="请选择是否公用" clearable>
  17. <el-option v-for="dict in sys_yes_no" :key="dict.value" :label="dict.label" :value="dict.value" />
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item label="所属部门" prop="deptId">
  21. <el-tree-select v-model="queryParams.deptId" :data="deptOptions"
  22. :props="{ value: 'id', label: 'label', children: 'children' }" value-key="id"
  23. placeholder="请选择归属部门" check-strictly @keyup.enter="handleQuery"/>
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  27. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  28. </el-form-item>
  29. </el-form>
  30. <el-row :gutter="10" class="mb8">
  31. <el-col :span="1.5">
  32. <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['scanner:info:add']">
  33. 新增
  34. </el-button>
  35. </el-col>
  36. <el-col :span="1.5">
  37. <el-button
  38. type="success"
  39. plain
  40. icon="Edit"
  41. :disabled="single"
  42. @click="handleUpdate"
  43. v-hasPermi="['scanner:info:edit']"
  44. >
  45. 修改
  46. </el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button
  50. type="danger"
  51. plain
  52. icon="Delete"
  53. :disabled="multiple"
  54. @click="handleDelete"
  55. v-hasPermi="['scanner:info:remove']"
  56. >
  57. 删除
  58. </el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['scanner:info:export']">
  62. 导出
  63. </el-button>
  64. </el-col>
  65. <el-col :span="1.5">
  66. <el-button
  67. type="info"
  68. plain
  69. icon="View"
  70. :disabled="single"
  71. @click="handleSee"
  72. >
  73. 查看FTP信息
  74. </el-button>
  75. </el-col>
  76. <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
  77. </el-row>
  78. <el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
  79. <el-table-column type="selection" width="55" align="center" />
  80. <el-table-column label="扫描仪编号" align="center" prop="scannerId" />
  81. <el-table-column label="扫描仪名称" align="center" prop="scannerName" />
  82. <el-table-column label="扫描仪IP" align="center" prop="scannerIp" />
  83. <el-table-column label="是否公用" align="center" prop="isPublic">
  84. <template #default="scope">
  85. <dict-tag :options="sys_yes_no" :value="scope.row.isPublic" />
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="FTP用户ID" align="center" prop="userId" />
  89. <el-table-column label="所属部门" align="center" prop="deptName" />
  90. <el-table-column label="创建人" align="center" prop="createBy" />
  91. <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  92. <template #default="scope">
  93. <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="更新人" align="center" prop="updateBy" />
  97. <el-table-column label="更新时间" align="center" prop="updateTime" width="180">
  98. <template #default="scope">
  99. <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  103. <template #default="scope">
  104. <el-button
  105. link
  106. type="primary"
  107. icon="Edit"
  108. @click="handleUpdate(scope.row)"
  109. v-hasPermi="['scanner:info:edit']"
  110. >
  111. 修改
  112. </el-button>
  113. <el-button
  114. link
  115. type="primary"
  116. icon="Delete"
  117. @click="handleDelete(scope.row)"
  118. v-hasPermi="['scanner:info:remove']"
  119. >
  120. 删除
  121. </el-button>
  122. </template>
  123. </el-table-column>
  124. </el-table>
  125. <pagination
  126. v-show="total > 0"
  127. :total="total"
  128. v-model:page="queryParams.pageNum"
  129. v-model:limit="queryParams.pageSize"
  130. @pagination="getList"
  131. />
  132. <!-- 添加或修改扫描仪管理对话框 -->
  133. <el-dialog :title="title" v-model="open" width="500px" append-to-body>
  134. <el-form ref="infoRef" :model="form" :rules="rules" label-width="100px">
  135. <el-form-item label="扫描仪名称" prop="scannerName">
  136. <el-input v-model="form.scannerName" placeholder="请输入扫描仪名称;" />
  137. </el-form-item>
  138. <el-form-item label="扫描仪IP" prop="scannerIp">
  139. <el-input v-model="form.scannerIp" placeholder="请输入扫描仪IP" />
  140. </el-form-item>
  141. <el-form-item label="是否公用" prop="isPublic">
  142. <el-radio-group v-model="form.isPublic">
  143. <el-radio v-for="dict in sys_yes_no" :key="dict.value" :label="dict.value">{{ dict.label }}</el-radio>
  144. </el-radio-group>
  145. </el-form-item>
  146. <!-- <el-form-item label="FTP用户ID" prop="userId">
  147. <el-input v-model="form.userId" placeholder="请输入FTP用户ID" />
  148. </el-form-item> -->
  149. <el-form-item label="所属部门" v-if="form.isPublic === 'N'" prop="deptId">
  150. <!-- <el-input v-model="form.deptId" placeholder="请输入所属部门" /> -->
  151. <el-tree-select v-model="form.deptId" :data="deptOptions"
  152. :props="{ value: 'id', label: 'label', children: 'children' }" value-key="id"
  153. placeholder="请选择归属部门" check-strictly />
  154. </el-form-item>
  155. </el-form>
  156. <template #footer>
  157. <div class="dialog-footer">
  158. <el-button type="primary" @click="submitForm">确 定</el-button>
  159. <el-button @click="cancel">取 消</el-button>
  160. </div>
  161. </template>
  162. </el-dialog>
  163. </div>
  164. </template>
  165. <script setup name="Info">
  166. import { addInfo, updateInfo, delInfo, getInfo, listInfo } from '@/api/scanner/info'
  167. import { encode, decode } from '@/utils/sm2util'
  168. import {
  169. deptTreeSelect,
  170. } from "@/api/system/user";
  171. import { ElMessageBox } from 'element-plus'
  172. const { proxy } = getCurrentInstance()
  173. const { sys_yes_no } = proxy.useDict('sys_yes_no')
  174. const infoList = ref([])
  175. const open = ref(false)
  176. const loading = ref(true)
  177. const showSearch = ref(true)
  178. const ids = ref([])
  179. const single = ref(true)
  180. const multiple = ref(true)
  181. const total = ref(0)
  182. const title = ref('')
  183. const deptOptions = ref(undefined);
  184. //ip验证
  185. const scannerIpRule = (rule, value, callback) => {
  186. var pPattern = new RegExp(
  187. /(\d{1,3}\.){3}\d{1,3}/
  188. );
  189. if (value === "") {
  190. callback(new Error("请输入扫描仪IP"));
  191. } else if (!pPattern.test(value)) {
  192. callback(new Error("请输入正确的IP地址"));
  193. } else {
  194. callback();
  195. }
  196. };
  197. const data = reactive({
  198. form: {
  199. },
  200. queryParams: {
  201. pageNum: 1,
  202. pageSize: 10,
  203. scannerName: null,
  204. scannerIp: null,
  205. isPublic: null,
  206. userId: null,
  207. deptId: null,
  208. createBy: null,
  209. createTime: null,
  210. updateBy: null,
  211. updateTime: null
  212. },
  213. rules: {
  214. scannerIp: [{ required: true, validator: scannerIpRule, trigger: "change" }],
  215. }
  216. })
  217. const { queryParams, form, rules } = toRefs(data)
  218. /** 查询扫描仪管理列表 */
  219. function getList() {
  220. loading.value = true
  221. listInfo(queryParams.value).then((response) => {
  222. infoList.value = response.rows
  223. total.value = response.total
  224. loading.value = false
  225. })
  226. }
  227. // 取消按钮
  228. function cancel() {
  229. open.value = false
  230. reset()
  231. }
  232. // 表单重置
  233. function reset() {
  234. form.value = {
  235. scannerId: null,
  236. scannerName: null,
  237. scannerIp: null,
  238. isPublic: "N",
  239. userId: null,
  240. deptId: null,
  241. createBy: null,
  242. createTime: null,
  243. updateBy: null,
  244. updateTime: null
  245. }
  246. proxy.resetForm('infoRef')
  247. }
  248. /** 搜索按钮操作 */
  249. function handleQuery() {
  250. queryParams.value.pageNum = 1
  251. getList()
  252. }
  253. /** 重置按钮操作 */
  254. function resetQuery() {
  255. proxy.resetForm('queryRef')
  256. handleQuery()
  257. }
  258. // 多选框选中数据
  259. function handleSelectionChange(selection) {
  260. ids.value = selection.map((item) => item.scannerId)
  261. single.value = selection.length != 1
  262. multiple.value = !selection.length
  263. }
  264. /** 新增按钮操作 */
  265. function handleAdd() {
  266. reset()
  267. open.value = true
  268. title.value = '添加扫描仪管理'
  269. }
  270. /** 修改按钮操作 */
  271. function handleUpdate(row) {
  272. reset()
  273. const _scannerId = row.scannerId || ids.value
  274. getInfo(_scannerId).then((response) => {
  275. form.value = response.data
  276. open.value = true
  277. title.value = '修改扫描仪管理'
  278. })
  279. }
  280. /** 提交按钮 */
  281. function submitForm() {
  282. proxy.$refs['infoRef'].validate((valid) => {
  283. if (valid) {
  284. if (form.value.scannerId != null) {
  285. updateInfo(form.value).then((response) => {
  286. proxy.$modal.msgSuccess('修改成功')
  287. open.value = false
  288. getList()
  289. })
  290. } else {
  291. addInfo(form.value).then((response) => {
  292. const data = response.data
  293. const pass=decode(data.pass);
  294. // const msg1=`新增扫描仪成功,请在扫描仪中配置ftp信息! \u000a 端口号:${data.port} \r 账号:${data.user} \u000a 密码:${pass}`
  295. // proxy.$modal.alertSuccess("新增扫描仪成功,请在扫描仪中配置ftp信息!"+`(端口号:${data.port}`)
  296. ElMessageBox.alert(
  297. `新增扫描仪成功,请在扫描仪中配置ftp信息!<br>端口号:${data.port}<br>账号:${data.user}<br>密码:${pass}`,
  298. '系统提示',
  299. {
  300. dangerouslyUseHTMLString: true,
  301. }
  302. )
  303. open.value = false
  304. getList()
  305. })
  306. }
  307. }else{
  308. proxy.$modal.msgError('请输入正确的信息')
  309. }
  310. })
  311. }
  312. /** 删除按钮操作 */
  313. function handleDelete(row) {
  314. const _scannerIds = row.scannerId || ids.value
  315. proxy.$modal
  316. .confirm('是否确认删除扫描仪管理编号为"' + _scannerIds + '"的数据项?')
  317. .then(function () {
  318. return delInfo(_scannerIds)
  319. })
  320. .then(() => {
  321. getList()
  322. proxy.$modal.msgSuccess('删除成功')
  323. })
  324. .catch(() => {})
  325. }
  326. /** 查询部门下拉树结构 */
  327. function getDeptTree() {
  328. deptTreeSelect().then(response => {
  329. deptOptions.value = response.data;
  330. });
  331. };
  332. /** 导出按钮操作 */
  333. function handleExport() {
  334. proxy.download(
  335. 'scanner/info/export',
  336. {
  337. ...queryParams.value
  338. },
  339. `info_${new Date().getTime()}.xlsx`
  340. )
  341. }
  342. /** 查看按钮操作 */
  343. function handleSee() {
  344. const url = location.href
  345. const arr = url.split('/')
  346. console.log('arr',arr);
  347. const row = infoList.value.find(item=>item.scannerId === ids.value[0])
  348. const pass=decode(row.pass);
  349. ElMessageBox.alert(
  350. `端口号:${row.port}<br>FTPIP:${arr[2]}<br>账号:${row.user}<br>密码:${pass}`,
  351. '扫描仪信息',
  352. {
  353. dangerouslyUseHTMLString: true,
  354. }
  355. )
  356. console.log('row',row);
  357. }
  358. getDeptTree();
  359. getList()
  360. </script>