CodeList.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. <template>
  2. <Breadcrumb pageTitle="爬虫列表"></Breadcrumb>
  3. <div class="space"></div>
  4. <el-card v-loading="loading">
  5. <el-header>
  6. <div class="action-bar-container">
  7. <el-space class="action-bar-item-container action-bar-action-left">
  8. <el-button-group class="ml-4">
  9. <el-button type="primary" :icon="Refresh" @click="resetFilterAndRefreshTableList">刷新</el-button>
  10. <el-button type="primary" :icon="Box" @click="clickClaimCodes" v-if="showRenLingButton">认领</el-button>
  11. </el-button-group>
  12. </el-space>
  13. <el-space class="action-bar-item-container action-bar-action-right">
  14. <div class="action-bar-item" v-if="showModifyUserFilter">
  15. <span class="action-bar-name">维护人:</span>
  16. <el-select v-model="filters.modifyuser" style="width: 110px" @change="onModifyUserSelectChange" :disabled="modifyUserSelectDisabled">
  17. <el-option
  18. v-for="item in filterConfig.modifyUserList"
  19. :key="item.value"
  20. :label="item.label"
  21. :value="item.value"
  22. />
  23. </el-select>
  24. </div>
  25. <div class="action-bar-item">
  26. <span class="action-bar-name">爬虫状态:</span>
  27. <el-select v-model="filters.state" placeholder="爬虫状态" style="width: 110px" @change="onStateSelectChange">
  28. <el-option
  29. v-for="item in filterConfig.stateOptions"
  30. :key="item.value"
  31. :label="item.label"
  32. :value="item.value"
  33. />
  34. </el-select>
  35. </div>
  36. <div class="action-bar-item">
  37. <span class="action-bar-name">认领状态:</span>
  38. <el-select v-model="filters.claimtype" placeholder="认领状态" style="width: 110px" @change="onClaimSelectChange">
  39. <el-option
  40. v-for="item in filterConfig.claimOptions"
  41. :key="item.value"
  42. :label="item.label"
  43. :value="item.value"
  44. :disabled="item.disabled"
  45. />
  46. </el-select>
  47. </div>
  48. <div class="action-bar-item">
  49. <el-input v-model="filters.search" placeholder="按照站点、爬虫代码搜索" @keydown.enter="onInputSearch" />
  50. </div>
  51. <div class="action-bar-item">
  52. <el-button type="primary" :icon="Search" @click="onInputSearch">搜索</el-button>
  53. </div>
  54. </el-space>
  55. </div>
  56. </el-header>
  57. <el-main>
  58. <el-table ref="spiderTable" :data="listState.list" stripe :row-style="getRowStyle" v-loading="listState.loading">
  59. <el-table-column prop="site" label="网站" align="center" show-overflow-tooltip></el-table-column>
  60. <el-table-column prop="channel" label="栏目" align="center" show-overflow-tooltip></el-table-column>
  61. <el-table-column prop="code" label="代码" align="center" show-overflow-tooltip></el-table-column>
  62. <el-table-column prop="stateText" label="爬虫状态" width="80" align="center" show-overflow-tooltip></el-table-column>
  63. <el-table-column prop="claimText" label="认领状态" width="100" align="center" show-overflow-tooltip></el-table-column>
  64. <el-table-column prop="href" label="栏目地址" show-overflow-tooltip></el-table-column>
  65. <el-table-column prop="modifyUserText" label="维护人" width="120" align="center" show-overflow-tooltip></el-table-column>
  66. <el-table-column label="操作" width="160" align="center">
  67. <template #default="scope">
  68. <!-- <el-tooltip content="标注" placement="top">
  69. <el-button size="small" :class="{ active: scope.row._action_clicked_mark }" @click="tableEvents.handleDataTag(scope.row)">
  70. <el-icon><Link /></el-icon>
  71. </el-button>
  72. </el-tooltip>-->
  73. <el-tooltip content="编辑" placement="top">
  74. <el-button size="small" :class="{ active: scope.row._action_clicked_edit }" @click="tableEvents.handleEdit(scope.$index, scope.row)">
  75. <el-icon><Edit /></el-icon>
  76. </el-button>
  77. </el-tooltip>
  78. <el-tooltip content="调试" placement="top">
  79. <el-button size="small" :class="{ active: scope.row._action_clicked_debug }" @click="tableEvents.handleDebug(scope.$index, scope.row)">
  80. <el-icon><SetUp /></el-icon>
  81. </el-button>
  82. </el-tooltip>
  83. <el-tooltip content="验证" placement="top">
  84. <el-button size="small" :class="{ active: scope.row._action_clicked_verify }" @click="tableEvents.handleVerify(scope.$index, scope.row)">
  85. <el-icon><Aim /></el-icon>
  86. </el-button>
  87. </el-tooltip>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="功能" width="120" align="center">
  91. <template #default="scope">
  92. <el-tooltip content="提交" placement="top" v-if="showListDevelopeButton">
  93. <!-- 爬虫状态是待完成,才可点击提交 -->
  94. <el-button size="small" :disabled="tableActionDisabled.submitDisabled(scope.row)" :class="{ active: scope.row._action_clicked_submit }" @click="tableEvents.handleSubmit(scope.$index, scope.row)">
  95. <el-icon><Promotion /></el-icon>
  96. </el-button>
  97. </el-tooltip>
  98. <el-tooltip content="退回" placement="top" v-if="showListRollbackButton">
  99. <!-- 爬虫状态是待完成,才可点击退回 -->
  100. <el-button size="small" :disabled="scope.row.state !== 0" :class="{ active: scope.row._action_clicked_rollback }" @click="tableEvents.handleRollback(scope.$index, scope.row)">
  101. <el-icon><DArrowLeft /></el-icon>
  102. </el-button>
  103. </el-tooltip>
  104. </template>
  105. </el-table-column>
  106. </el-table>
  107. <div class="space"></div>
  108. <div class="pagination-container">
  109. <el-pagination align="right" @size-change="handleSizeChange" @current-change="handleCurrentChange"
  110. :current-page="listState.pageNum" :page-sizes="[10, 20, 30, 40]" :page-size="listState.pageSize"
  111. layout="total, sizes, prev, pager, next, jumper" :total="listState.total">
  112. </el-pagination>
  113. </div>
  114. </el-main>
  115. </el-card>
  116. <EditSpider ref="editSpiderDialog"
  117. @custom-event="dialogEvents.editSpiderConfigSaveEvent"
  118. @data-tag="editDialogMarkClick($event)"
  119. @form-change="onEditFormChange"
  120. />
  121. <RunSpiderDialog ref="runSpiderDialog" />
  122. <VerifySpider ref="verifySpiderDialog" />
  123. </template>
  124. <script setup>
  125. import { ref, computed, onMounted, onUnmounted, reactive, watch } from 'vue'
  126. import { useRouter } from 'vue-router';
  127. import { useStore } from 'vuex';
  128. import { ElMessage, ElMessageBox } from 'element-plus'
  129. import { BrowserOpenURL, EventsOn } from "../../wailsjs/runtime"
  130. import { VerifySpiderConfig, ServerActionUpdateCodeState, ServerActionCurrentOpenTab } from "../../wailsjs/go/main/App"
  131. import Breadcrumb from "../components/Breadcrumb.vue"
  132. import EditSpider from "../components/spider/EditSpider.vue"
  133. import RunSpiderDialog from "../components/spider/RunSpiderDialog.vue"
  134. import VerifySpider from "../components/spider/VerifySpider.vue"
  135. import { useCodeListFiltersWithRole } from '../composables/filter-options'
  136. import { USER_ROLE_ADMIN, USER_ROLE_DEVELOPER, USER_ROLE_REVIEWER } from '../data/user'
  137. import { Refresh, Search, Box } from '@element-plus/icons-vue'
  138. const router = useRouter();
  139. const store = useStore();
  140. const spiderTable = ref(null)
  141. const { stateOptions, claimOptions } = useCodeListFiltersWithRole()
  142. const loading = ref(false)
  143. const filterConfig = reactive({
  144. // 爬虫状态备选项
  145. stateOptions: stateOptions,
  146. // 认领状态备选项
  147. claimOptions: claimOptions,
  148. // 维护人备选项
  149. modifyUserList: [
  150. {
  151. label: '全部',
  152. value: '-1',
  153. }
  154. ]
  155. })
  156. // 选择器数据
  157. const filters = reactive({
  158. // 搜索
  159. search: '',
  160. // 爬虫状态
  161. state: -1,
  162. // 维护人
  163. modifyuser: '-1',
  164. // 认领状态
  165. claimtype: -1,
  166. })
  167. // 选择器数据(用来重置)
  168. const defaultFilters = {
  169. search: '',
  170. state: -1,
  171. modifyuser: '-1',
  172. claimtype: -1,
  173. }
  174. // 列表数据
  175. const listState = reactive({
  176. loaded: false,
  177. loading: false,
  178. pageNum: 1, // 页码
  179. pageSize: 10, // 每页多少条
  180. total: 0, // 返回的总数据条数
  181. list: [ // 数据列表
  182. // {
  183. // code: '爬虫代码',
  184. // site: '网站',
  185. // channel: '栏目',
  186. // href: '栏目地址',
  187. // modifyuser: '维护人',
  188. // _id: 'asfasf',
  189. // },
  190. ],
  191. })
  192. // 列表默认数据(用来重置)
  193. const defaultListState = {
  194. loaded: false,
  195. loading: false,
  196. pageNum: 1,
  197. pageSize: 10,
  198. total: 0,
  199. list: [],
  200. }
  201. // 当前编辑的row的数据
  202. const currentEditRow = ref({})
  203. // 上一个点击的row的数据
  204. const prevClickedRow = ref({})
  205. // 用户身份标识
  206. const userRole = computed(() => store.getters.userRole)
  207. // 是否展示维护人模块(管理员和审核员展示)
  208. const showModifyUserFilter = computed(() => [USER_ROLE_ADMIN, USER_ROLE_REVIEWER].includes(userRole.value))
  209. // 是否展示认领按钮(仅开发人员展示)
  210. const showRenLingButton = computed(() => [USER_ROLE_DEVELOPER].includes(userRole.value))
  211. // 是否展示提交按钮(仅开发人员展示)
  212. const showListDevelopeButton = computed(() => [USER_ROLE_DEVELOPER].includes(userRole.value))
  213. // 是否展示退回按钮(仅开发人员展示)
  214. const showListRollbackButton = computed(() => [USER_ROLE_DEVELOPER].includes(userRole.value))
  215. // 实现待认领不能和维护人同时筛选
  216. // 是否禁用维护人模块(待认领筛选下,禁用维护人筛选模块)
  217. const modifyUserSelectDisabled = computed(() => filters.claimtype === 0)
  218. // 是否禁用待认领筛选(维护人不为全部,则禁用待认领的选中)
  219. const stopWatch = watch(() => filters.modifyuser, (n) => {
  220. const target = filterConfig.claimOptions.find(i => i.value === 0)
  221. if (target) {
  222. if (n === defaultFilters.modifyuser) {
  223. // 解除禁用待认领
  224. target.disabled = false
  225. } else {
  226. // 禁用待认领
  227. target.disabled = true
  228. }
  229. } else {
  230. stopWatch()
  231. }
  232. })
  233. const editSpiderDialog = ref(null)
  234. const runSpiderDialog = ref(null)
  235. const verifySpiderDialog = ref(null)
  236. // 取消prevClicked的高亮
  237. const cancelOtherHighlight = () => {
  238. for (const key in prevClickedRow.value) {
  239. if (key.includes('_action_clicked')) {
  240. prevClickedRow.value[key] = false
  241. }
  242. }
  243. }
  244. // 页面按钮点击高亮
  245. const onlyClickHighlight = (row, key) => {
  246. cancelOtherHighlight()
  247. row[key] = true
  248. prevClickedRow.value = row
  249. }
  250. const getRowStyle = ({ row }) => {
  251. return row.selected ? { backgroundColor: '#F7F7F7' } : {};
  252. };
  253. // 计算爬虫状态
  254. const calcStateText = (state) => {
  255. const target = filterConfig.stateOptions.find(r => r.value === state)
  256. if (target) {
  257. return target.label
  258. } else {
  259. return ''
  260. }
  261. }
  262. // 计算认领状态
  263. const calcClaimText = (state) => {
  264. const target = filterConfig.claimOptions.find(r => r.value === state)
  265. if (target) {
  266. return target.label
  267. } else {
  268. return ''
  269. }
  270. }
  271. const calcModifyUserText = (state) => {
  272. // 未认领状态。维护人返回无
  273. if (state.claimtype === 0) {
  274. return '无'
  275. } else {
  276. return state.modifyuser
  277. }
  278. }
  279. // 获取列表数据
  280. async function getTableList() {
  281. listState.loading = true
  282. try {
  283. const r = await store.dispatch('rulesList/getCodeList', {
  284. modifyuser: filters.modifyuser, // 维护人
  285. state: filters.state, // 爬虫状态
  286. search: filters.search, // 搜索内容
  287. claimtype: filters.claimtype,
  288. pageType: 'codelist',
  289. pageSize: listState.pageSize,
  290. pageNum: listState.pageNum
  291. });
  292. const { data, err, msg } = r
  293. if (data) {
  294. listState.total = data.total || 0
  295. if (Array.isArray(data.list)) {
  296. const sList = data.list.map(t => {
  297. return {
  298. ...t,
  299. stateText: calcStateText(t.state),
  300. claimText: calcClaimText(t.claimtype),
  301. modifyUserText: calcModifyUserText(t),
  302. // 操作按钮是否点击过
  303. _action_clicked_mark: false,
  304. _action_clicked_edit: false,
  305. _action_clicked_debug: false,
  306. _action_clicked_verify: false,
  307. _action_clicked_submit: false,
  308. _action_clicked_rollback: false,
  309. }
  310. })
  311. listState.list = sList || []
  312. }
  313. }
  314. } catch (error) {
  315. listState.loaded = true
  316. } finally {
  317. listState.loading = false
  318. }
  319. }
  320. // 重置列表数据
  321. const resetListState = () => {
  322. Object.assign(listState, defaultListState)
  323. }
  324. // 重置选择器数据
  325. const resetFilterState = () => {
  326. Object.assign(filters, defaultFilters)
  327. }
  328. // 刷新列表(不重置选择器)
  329. function refreshTableList() {
  330. resetListState()
  331. getTableList()
  332. }
  333. // 刷新列表(并重置选择器)
  334. function resetFilterAndRefreshTableList() {
  335. resetFilterState()
  336. refreshTableList()
  337. }
  338. // 认领按钮事件
  339. const userClaimCodes = async () => {
  340. try {
  341. const r = await store.dispatch('rulesList/userClaimCodes')
  342. const { msg, err } = r
  343. if (err === 1) {
  344. ElMessage({
  345. message: msg || '认领成功',
  346. type: 'success',
  347. duration: 3000,
  348. })
  349. resetFilterAndRefreshTableList()
  350. } else {
  351. ElMessage({
  352. message: msg || '认领失败',
  353. type: 'error',
  354. duration: 3000,
  355. })
  356. }
  357. } catch (error) {
  358. ElMessage({
  359. message: '认领失败',
  360. type: 'error',
  361. duration: 3000,
  362. })
  363. }
  364. }
  365. const clickClaimCodes = () => {
  366. ElMessageBox.confirm('确定要认领爬虫?', '提示',
  367. {
  368. customClass: 'j-confirm-message-box',
  369. type: 'warning',
  370. confirmButtonText: '确定',
  371. cancelButtonText: '取消',
  372. showCancelButton: false,
  373. }
  374. ).then(() => {
  375. userClaimCodes()
  376. })
  377. }
  378. getTableList()
  379. const handleSizeChange = (val) => {
  380. listState.pageSize = val;
  381. listState.pageNum = 1;
  382. getTableList()
  383. };
  384. const handleCurrentChange = (val) => {
  385. listState.pageNum = val;
  386. getTableList()
  387. };
  388. // 获取维护人劣列表
  389. const getModifyUserList = async () => {
  390. const r = await store.dispatch('rulesList/getModifyUserList')
  391. const { data, err, msg } = r
  392. if (data) {
  393. if (Array.isArray(data.list)) {
  394. const arr = filterConfig.modifyUserList
  395. const reqArr = data.list.map(r => {
  396. return {
  397. label: r.s_name,
  398. value: r.s_name,
  399. }
  400. })
  401. filterConfig.modifyUserList = arr.concat(reqArr)
  402. }
  403. }
  404. }
  405. getModifyUserList()
  406. const onModifyUserSelectChange = () => {
  407. refreshTableList()
  408. }
  409. const onStateSelectChange = () => {
  410. refreshTableList()
  411. }
  412. const onInputSearch = () => {
  413. refreshTableList()
  414. }
  415. const onClaimSelectChange = () => {
  416. refreshTableList()
  417. }
  418. // 保存完成后(不刷新优化),同步更新表单内的数据
  419. const refreshRowData = (code, payload) => {
  420. const target = listState.list.find(item => item.code === code)
  421. if (target) {
  422. if (target.cssmark) {
  423. Object.assign(target.cssmark, payload)
  424. } else {
  425. target.cssmark = payload
  426. }
  427. }
  428. }
  429. // 更新编辑弹窗数据
  430. const refreshAndAsyncEditDialog = (key, value) => {
  431. editSpiderDialog.value.refreshPageData(key, value)
  432. }
  433. // 打开编辑弹窗(如果传数据了,则恢复数据)
  434. const openEditDialog = (row) => {
  435. editSpiderDialog.value.dialogVisible = true
  436. if (row) {
  437. editSpiderDialog.value.setPageData({
  438. ...row,
  439. ...row.cssmark,
  440. })
  441. }
  442. }
  443. const dialogEvents = {
  444. editSpiderConfigSaveEvent: async function (data) {
  445. // 整理数据结构
  446. // [{ query: {code: 'code'}, set: {} }, {query:{},set:{}}]
  447. const rowData = data._originData
  448. const payload = data.value
  449. const code = rowData.code
  450. const updateRule = [
  451. {
  452. query: { code: code },
  453. set: {
  454. cssmark: payload,
  455. }
  456. }
  457. ]
  458. const params = {
  459. stype: 'save',
  460. update: updateRule
  461. }
  462. console.log("change data:", data, params)
  463. try {
  464. const r = await store.dispatch('rulesList/editCodeItem', params)
  465. const { msg, err } = r
  466. if (err === 1) {
  467. refreshRowData(code, payload)
  468. ElMessage({
  469. message: msg || '保存成功',
  470. type: 'success',
  471. duration: 3000,
  472. })
  473. // getTableList()
  474. } else {
  475. ElMessage({
  476. message: msg || '保存失败',
  477. type: 'error',
  478. duration: 3000,
  479. })
  480. }
  481. } catch (error) {
  482. ElMessage({
  483. message: '保存失败',
  484. type: 'error',
  485. duration: 3000,
  486. })
  487. }
  488. },
  489. }
  490. const getMarkWithRow = row => {
  491. const baseInfo = {
  492. code: row.code,
  493. site: row.site,
  494. channel: row.channel,
  495. href: row.href,
  496. modifyuser: row.modifyuser,
  497. }
  498. if (row.cssmark) {
  499. return {
  500. ...row.cssmark,
  501. ...baseInfo,
  502. }
  503. } else {
  504. return baseInfo
  505. }
  506. }
  507. // 根据编辑弹窗的内容,获取cssMark
  508. const getMarkWithEditDialogInfo = info => {
  509. const { value, _originData } = info
  510. const baseInfo = {
  511. code: _originData.code,
  512. site: _originData.site,
  513. channel: _originData.channel,
  514. href: _originData.href,
  515. modifyuser: _originData.modifyuser,
  516. }
  517. return {
  518. ...value,
  519. ...baseInfo,
  520. }
  521. }
  522. const getLuaParams = row => {
  523. const baseInfo = {
  524. code: row.code,
  525. site: row.site,
  526. channel: row.channel,
  527. modifyuser: row.modifyuser,
  528. claimtime: row.claimtime,
  529. recovertime: row.recovertime,
  530. priority: row.priority,
  531. spiderimportant: row.spiderimportant,
  532. modifytime: row.modifytime,
  533. }
  534. return baseInfo
  535. }
  536. const editDialogMarkClick = (row) => {
  537. // 自定义关闭时间
  538. ElMessage({
  539. message: `${row.site} ${row.channel} ${row.href}`,
  540. showClose: true,
  541. duration: 3000,
  542. });
  543. BrowserOpenURL(row.href)
  544. }
  545. // table的按钮事件集合
  546. const tableEvents = {
  547. handleDataTag(row) {
  548. onlyClickHighlight(row, '_action_clicked_mark')
  549. // 自定义关闭时间
  550. editDialogMarkClick(row)
  551. },
  552. handleEdit: (index, row) => {
  553. currentEditRow.value = row
  554. onlyClickHighlight(row, '_action_clicked_edit')
  555. prevClickedRow.value = row
  556. ElMessage({
  557. message: `${row.site} ${row.channel} ${row.href}`,
  558. showClose: true,
  559. duration: 3000,
  560. });
  561. const mark = getMarkWithRow(row)
  562. ServerActionCurrentOpenTab(mark)
  563. openEditDialog(row)
  564. },
  565. handleDebug(index, row) {
  566. onlyClickHighlight(row, '_action_clicked_debug')
  567. runSpiderDialog.value.dialogVisible = true
  568. runSpiderDialog.value.setPageData(row)
  569. // router.push({
  570. // path: '/run'
  571. // });
  572. },
  573. handleVerify(index, row) {
  574. onlyClickHighlight(row, '_action_clicked_verify')
  575. loading.value = true
  576. if (!row.cssmark) {
  577. return ElMessage({
  578. message: '没有找到标注信息',
  579. type: 'error',
  580. duration: 3000,
  581. })
  582. }
  583. const mark = getMarkWithRow(row)
  584. VerifySpiderConfig(mark).then(r => {
  585. if (r.err === 1 && r.ret) {
  586. verifySpiderDialog.value.dialogVisible = true
  587. verifySpiderDialog.value.formData = r.ret
  588. } else {
  589. return ElMessage({
  590. message: r.msg || '验证异常',
  591. type: 'error',
  592. duration: 3000,
  593. })
  594. }
  595. }).finally(() => {
  596. loading.value = false
  597. })
  598. },
  599. handleSubmit(index, row) {
  600. onlyClickHighlight(row, '_action_clicked_submit')
  601. const lua = getLuaParams(row)
  602. lua.state = 1
  603. ServerActionUpdateCodeState({ lua: lua }).then(r => {
  604. if (r.err === 1) {
  605. ElMessage({
  606. message: '提交成功',
  607. type: 'success',
  608. duration: 3000,
  609. })
  610. getTableList()
  611. } else {
  612. return ElMessage({
  613. message: r.msg || '提交失败',
  614. type: 'error',
  615. duration: 3000,
  616. })
  617. }
  618. })
  619. },
  620. handleRollback(_, row) {
  621. onlyClickHighlight(row, '_action_clicked_rollback')
  622. // ElMessageBox.alert('确定退回?', '提示', {
  623. // customClass: 'j-confirm-message-box',
  624. // confirmButtonText: '确定',
  625. // callback: (action) => {
  626. // if (action === 'confirm') {
  627. //
  628. // }
  629. // },
  630. // })
  631. ElMessageBox.confirm('确定退回?', '提示',
  632. {
  633. customClass: 'j-confirm-message-box',
  634. type: 'warning',
  635. confirmButtonText: '确定',
  636. cancelButtonText: '取消',
  637. showCancelButton: false,
  638. }
  639. ).then(() => {
  640. this.confirmRollback(row)
  641. })
  642. },
  643. confirmRollback(row) {
  644. const lua = getLuaParams(row)
  645. lua.state = 12
  646. ServerActionUpdateCodeState({ lua: lua }).then(r => {
  647. if (r.err === 1) {
  648. ElMessage({
  649. message: '退回成功',
  650. type: 'success',
  651. duration: 3000,
  652. })
  653. getTableList()
  654. } else {
  655. return ElMessage({
  656. message: r.msg || '退回失败',
  657. type: 'error',
  658. duration: 3000,
  659. })
  660. }
  661. })
  662. },
  663. }
  664. // 表格按钮是否可用
  665. const tableActionDisabled = {
  666. // 此按钮是开发者才会展示
  667. submitDisabled(row) {
  668. // 开发者-爬虫状态是待完成,才可点击提交
  669. const waitingComplete = row.state === 0
  670. // 开发者-未通过的爬虫可点击提交
  671. const notPass = row.state === 2
  672. const canSubmit = waitingComplete || notPass
  673. return !canSubmit
  674. }
  675. }
  676. const onEditFormChange = (info) => {
  677. const mark = getMarkWithEditDialogInfo(info)
  678. ServerActionCurrentOpenTab(mark)
  679. }
  680. //Wails事件绑定
  681. EventsOn("spiderConfigChange", data => {
  682. console.log(data)
  683. const { key, css, url } = data
  684. refreshAndAsyncEditDialog(key, css)
  685. // 当触发修改时候,同步给客服端一份
  686. if (currentEditRow.value && Object.keys(currentEditRow.value).length <= 0) {
  687. const mark = getMarkWithRow(currentEditRow.value)
  688. ServerActionCurrentOpenTab(mark)
  689. }
  690. // 判断标注url和编辑url是否相同
  691. // const editUrl = currentEditRow.href
  692. // if (url === editUrl) {
  693. // refreshAndAsyncEditDialog(key, css[key])
  694. // } else {
  695. // ElMessage({
  696. // message: `标注url和编辑url不匹配,此次更新取消。当前标注url: ${url},当前编辑url: ${editUrl}`,
  697. // type: 'warn',
  698. // duration: 4000,
  699. // })
  700. // }
  701. })
  702. </script>
  703. <style lang="scss" scoped>
  704. ::v-deep {
  705. .el-button {
  706. &.active {
  707. background-color: var(--el-button-hover-bg-color);
  708. border-color: var(--el-button-hover-border-color);
  709. color: var(--el-button-hover-text-color);
  710. outline: none;
  711. }
  712. }
  713. }
  714. .pagination-container {
  715. display: flex;
  716. align-items: center;
  717. justify-content: flex-end;
  718. }
  719. .action-bar-container {
  720. display: flex;
  721. justify-content: space-between;
  722. }
  723. .action-bar-item-container {
  724. }
  725. .action-bar-item {
  726. display: flex;
  727. align-items: center;
  728. }
  729. .action-bar-name {
  730. font-size: 14px;
  731. white-space: nowrap;
  732. }
  733. </style>