postSkill.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933
  1. <template>
  2. <div>
  3. <!-- 关键:用flex布局强制横向排列,禁止换行 -->
  4. <div class="button-toolbar" style="margin-bottom: 20px;">
  5. <!-- 按钮组:刷新 + 添加 + 导入 -->
  6. <el-button-group class="btn-group">
  7. <!-- 刷新按钮 -->
  8. <el-button
  9. size="default"
  10. type="primary"
  11. @click="cancel"
  12. style="margin-right: 10px;"
  13. >
  14. 刷新
  15. </el-button>
  16. <!-- 添加按钮 -->
  17. <el-button
  18. size="default"
  19. type="primary"
  20. :disabled="!isAuth('positionList:add')"
  21. @click="classAdd(1)"
  22. style="margin-right: 10px;"
  23. >
  24. 添加
  25. </el-button>
  26. <!-- Excel导入按钮(核心:强制inline-block,消除换行) -->
  27. <el-upload
  28. class="upload-btn-wrapper"
  29. action="#"
  30. :auto-upload="false"
  31. :on-change="handleFileChange"
  32. :on-remove="handleFileRemove"
  33. :file-list="fileList"
  34. accept=".xlsx,.xls"
  35. :show-file-list="false"
  36. style="display: inline-block;"
  37. :disabled="!isAuth('positionList:import')"
  38. >
  39. <el-button
  40. size="default"
  41. type="primary"
  42. style="margin-right: 5px;"
  43. >
  44. 导入Excel
  45. </el-button>
  46. </el-upload>
  47. </el-button-group>
  48. <!-- 确认导入按钮(可选,同排显示) -->
  49. <el-button
  50. v-if="fileList.length"
  51. size="default"
  52. type="success"
  53. @click="handleImport"
  54. >
  55. 确认导入
  56. </el-button>
  57. </div>
  58. <!-- <div style="width: 100%;text-align: right;">
  59. <div class="excel-import-container">
  60. <el-upload
  61. class="upload-excel"
  62. action="#"
  63. :auto-upload="false"
  64. :on-change="handleFileChange"
  65. :on-remove="handleFileRemove"
  66. :file-list="fileList"
  67. accept=".xlsx,.xls"
  68. drag
  69. >
  70. <i class="el-icon-upload"></i>
  71. <div class="el-upload__text">
  72. 将文件拖到此处,或<em>点击上传</em>
  73. </div>
  74. <div class="el-upload__tip" slot="tip">
  75. 仅支持.xls/.xlsx格式文件,单个文件大小不超过10MB
  76. </div>
  77. </el-upload>
  78. <br></br>
  79. <el-button
  80. type="primary"
  81. icon="el-icon-upload2"
  82. @click="handleImport"
  83. :disabled="!fileList.length"
  84. style="margin-top: 20px;"
  85. >
  86. 确认导入
  87. </el-button>
  88. <el-button style="margin-bottom: 20px;" size="" type="primary" @click="cancel">刷新
  89. </el-button>
  90. <el-button style="margin:10px;" size="" type="primary" icon="document"
  91. :disabled="!isAuth('positionList:add')" @click="classAdd(1)">添加
  92. </el-button>
  93. </div>
  94. </div> -->
  95. <!-- 职业方向-->
  96. <el-table v-loading="tableDataLoading" :data="tableData.records">
  97. <el-table-column prop="postSkillId" label="编号" width="160">
  98. </el-table-column>
  99. <el-table-column prop="postSkillName" label="职业方向">
  100. </el-table-column>
  101. <el-table-column prop="sort" label="排序">
  102. </el-table-column>
  103. <el-table-column prop="isEnable" label="状态" >
  104. <template slot-scope="scope">
  105. <el-switch v-model="scope.row.isEnable" @change="change(scope.row.postSkillId,scope.row.isEnable,scope.row)"
  106. :disabled="!isAuth('positionList:update')" :active-value="openValue2"
  107. :inactive-value="closeValue2" active-color="#13ce66" inactive-color="#ff4949">
  108. </el-switch>
  109. </template>
  110. </el-table-column>
  111. <!-- <el-table-column prop="ruleClassifyId" label="岗位ID" width="160">
  112. </el-table-column> -->
  113. <el-table-column prop="ruleClassifyName" label="岗位名称" >
  114. </el-table-column>
  115. <el-table-column prop="updateTime" label="更新时间" width="180">
  116. </el-table-column>
  117. <el-table-column label="操作" prop="id" width="200" fixed='right' align="center">
  118. <template slot-scope="scope">
  119. <el-button size="mini" type="primary" style="margin: 5px;"
  120. @click="classList(scope.row,2)">职业技能列表
  121. </el-button>
  122. <el-button size="mini" type="primary" :disabled="!isAuth('positionList:update')" style="margin: 5px;"
  123. @click="classAdd(0,scope.row)">修改
  124. </el-button>
  125. <el-button size="mini" type="danger" :disabled="!isAuth('positionList:delete')" style="margin: 5px;"
  126. @click="classdelete(scope.row)">删除
  127. </el-button>
  128. </template>
  129. </el-table-column>
  130. </el-table>
  131. <div style="text-align: center;margin-top: 10px;">
  132. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
  133. :page-sizes="[10, 20, 30, 40]" :page-size="limit" :current-page="page"
  134. layout="total,sizes, prev, pager, next,jumper" :total="tableData.total">
  135. </el-pagination>
  136. </div>
  137. <!-- </el-tab-pane> -->
  138. <!-- 图片展示-->
  139. <el-dialog title="二级岗位列表" :visible.sync="dialogVisible" width="70%" center>
  140. <div style="margin:2% 0;display: inline-block;">
  141. <el-button style='margin-left:15px;' size="mini" type="primary" icon="document" @click="classAdd(2)">
  142. 添加
  143. </el-button>
  144. </div>
  145. <el-table v-loading="tableDataLoading4" :data="stationList.records">
  146. <el-table-column prop="postSkillId" label="编号" width="160">
  147. </el-table-column>
  148. <el-table-column prop="postSkillName" label="职业技能">
  149. </el-table-column>
  150. <el-table-column prop="sort" label="排序">
  151. </el-table-column>
  152. <el-table-column prop="isEnable" label="状态">
  153. <template slot-scope="scope">
  154. <el-switch v-model="scope.row.isEnable" @change="change(scope.row.postSkillId,scope.row.isEnable,scope.row)"
  155. :disabled="!isAuth('positionList:update')" :active-value="openValue2"
  156. :inactive-value="closeValue2" active-color="#13ce66" inactive-color="#ff4949">
  157. </el-switch>
  158. </template>
  159. </el-table-column>
  160. <!-- <el-table-column prop="ruleClassifyId" label="岗位ID" >
  161. </el-table-column> -->
  162. <el-table-column prop="ruleClassifyName" label="岗位名称" >
  163. </el-table-column>
  164. <el-table-column prop="updateTime" label="更新时间" width="180">
  165. </el-table-column>
  166. <el-table-column label="操作" fixed='right' width="180">
  167. <template slot-scope="scope">
  168. <el-button size="mini" type="primary" :disabled="!isAuth('positionList:update')"
  169. @click="classAdd(0,scope.row,2)">修改
  170. </el-button>
  171. <el-button size="mini" type="danger" :disabled="!isAuth('positionList:delete')"
  172. @click="stationDelete(scope.row)">删除
  173. </el-button>
  174. </template>
  175. </el-table-column>
  176. </el-table>
  177. <div style="text-align: center;margin-top: 10px;">
  178. <el-pagination @size-change="handleSizeChangeGw" @current-change="handleCurrentChangeGw"
  179. :page-sizes="[5, 10, 15, 20]" :page-size="size1" :current-page="page1"
  180. layout="total,sizes, prev, pager, next,jumper" :total="stationList.total">
  181. </el-pagination>
  182. </div>
  183. </el-dialog>
  184. <!-- 添加、修改职业技能 -->
  185. <el-dialog :title="titles" :visible.sync="dialogFormVisible9" center>
  186. <div style="margin-bottom: 10px;position: relative;">
  187. <div style="width: 200px;display: inline-block;text-align: right;position: absolute;top: 0;">所属岗位:</div>
  188. <div class="ruleitem" style="display: inline-block;margin-left: 200px;">
  189. <div>
  190. <span>一级岗位分类:<el-radio v-for="(item,index) in yijiData" :key="index" v-model="yijiid"
  191. :label="item.ruleClassifyId"
  192. @change="yijiBtn(yijiid)">{{item.ruleClassifyName}}</el-radio></span>
  193. </div>
  194. <div v-if="yijiid!=''">
  195. <span>二级级岗位分类:<el-radio v-for="(item,index) in erjiData" :key="index" v-model="erjiId"
  196. :label="item.ruleClassifyId"
  197. @change="erjiBtn(erjiId)">{{item.title}}</el-radio></span>
  198. </div>
  199. <div v-if="erjiId!=''">
  200. <span>岗位名称:<el-radio v-for="(item,index) in sanjiData" :key="index" v-model="sanjiTypr"
  201. :label="item.ruleClassifyId">{{item.ruleClassifyName}}</el-radio></span>
  202. </div>
  203. </div>
  204. </div>
  205. <div style="margin-bottom: 10px;" v-if="parentId==0">
  206. <span style="width: 200px;display: inline-block;text-align: right;">职业方向名称:</span>
  207. <el-input style="width:50%;" v-model="postSkillName" type="text" placeholder="请输入职业方向名称"></el-input>
  208. </div>
  209. <div style="margin-bottom: 10px;" v-if="parentId!=0">
  210. <span style="width: 200px;display: inline-block;text-align: right;">职业技能名称:</span>
  211. <el-input style="width:50%;" v-model="postSkillName" type="text" placeholder="请输入职业技能名称"></el-input>
  212. </div>
  213. <div style="margin-bottom: 10px;display:flex;">
  214. <span style="width: 200px;display: inline-block;text-align: right;">排序:</span>
  215. <el-input-number size="medium" v-model="sort"></el-input-number>
  216. </div>
  217. <div style="margin-bottom: 10px;display:flex;">
  218. <span style="width: 200px;display: inline-block;text-align: right;">状态:</span>
  219. <el-radio-group v-model="gameStatus">
  220. <el-radio :label="1">启用</el-radio>
  221. <el-radio :label="0">禁用</el-radio>
  222. </el-radio-group>
  223. </div>
  224. <div slot="footer" class="dialog-footer">
  225. <el-button @click="dialogFormVisible9 = false">取 消</el-button>
  226. <el-button type="primary" @click="refuseto1()">确 定</el-button>
  227. </div>
  228. </el-dialog>
  229. <!-- </el-tabs> -->
  230. </div>
  231. </template>
  232. <script>
  233. export default {
  234. data() {
  235. return {
  236. size: 10,
  237. page: 1,
  238. size1: 10,
  239. page1: 1,
  240. limit: 10,
  241. openValue2: 1,
  242. closeValue2: 0,
  243. title: '',
  244. type: '',
  245. name: '',
  246. activeName: 'first',
  247. tableDataLoading: true,
  248. tableDataLoading4: false,
  249. dialogFormVisible9: false,
  250. dialogVisible: false,
  251. tableData: {},
  252. titles: '添加服务分类',
  253. ruleClassifyId: '',
  254. sort:1,
  255. gameStatus: 1,
  256. stationList:{},
  257. postSkillId:'',
  258. postSkillName:'',
  259. flname:'',
  260. parentId:0,
  261. parentIdEr:'',
  262. postSkillIdT: '',
  263. ruleClassifyName: '',
  264. yijiid: '',
  265. erjiId: '',
  266. yijiData: [],
  267. erjiData: [],
  268. sanjiData: [],
  269. erjiTypr: true,
  270. sanjiTypr: '',
  271. fileList: []
  272. }
  273. },
  274. methods: {
  275. handleSizeChange(val) {
  276. this.limit = val
  277. this.classSelect()
  278. },
  279. handleCurrentChange(val) {
  280. this.page = val
  281. this.classSelect()
  282. },
  283. handleSizeChangeGw(val) {
  284. this.size1 = val
  285. this.stationClass()
  286. },
  287. handleCurrentChangeGw(val) {
  288. this.page1 = val
  289. this.stationClass()
  290. },
  291. handleClick(tab, event) {
  292. this.page = 1
  293. if (tab._props.label == '岗位分类') {
  294. this.classSelect()
  295. }
  296. },
  297. // 取消
  298. cancel() {
  299. this.page = 1
  300. this.classSelect()
  301. },
  302. // 获取服务分类数据
  303. classSelect() {
  304. this.tableDataLoading = true
  305. this.$http({
  306. url: this.$http.adornUrl('postSkill/selectPostSkillList'),
  307. method: 'get',
  308. params: this.$http.adornParams({
  309. 'page': this.page,
  310. 'limit': this.limit,
  311. })
  312. }).then(({
  313. data
  314. }) => {
  315. if (data.code == 0) {
  316. this.tableDataLoading = false
  317. let returnData = data.data
  318. this.tableData = returnData
  319. } else {
  320. this.$notify({
  321. title: '提示',
  322. duration: 1800,
  323. message: data.msg,
  324. type: 'warning'
  325. });
  326. }
  327. })
  328. },
  329. // 添加服务分类
  330. classAdd(index,row,jibie) { // index 1添加职业方向 2添加职业技能, 0修改 // jibie 1职业方向 2职业技能
  331. console.log(index,'row', row)
  332. this.classSelectYiji();
  333. if (index==0) {
  334. this.titles = '修改职业方向'
  335. this.postSkillName = row.postSkillName
  336. this.postSkillId = row.postSkillId
  337. this.sort = row.sort
  338. this.parentId = row.parentId;
  339. this.gameStatus = row.isEnable
  340. this.ruleClassifyId = row.ruleClassifyId
  341. this.sanjiTypr = ''
  342. this.erjiId = ''
  343. this.yijiid = ''
  344. if(jibie==2){
  345. this.titles = '修改职业技能'
  346. }
  347. } else {
  348. this.titles = '添加职业方向'
  349. if(jibie==2){
  350. this.titles = '添加职业技能'
  351. }
  352. if(index==1){
  353. this.parentId = 0
  354. }else if(index==2){
  355. this.parentId = this.postSkillIdT
  356. }
  357. this.postSkillId=''
  358. this.ruleClassifyId = ''
  359. this.postSkillName = ''
  360. this.sort = 1
  361. this.gameStatus = 1
  362. this.sanjiTypr = ''
  363. this.erjiId = ''
  364. this.yijiid = ''
  365. }
  366. this.dialogFormVisible9 = true
  367. },
  368. // 获取一级岗位数据
  369. classSelectYiji() {
  370. this.$http({
  371. url: this.$http.adornUrl('admin/rule/adminGetClassifyList'),
  372. method: 'get',
  373. params: this.$http.adornParams({
  374. })
  375. }).then(({
  376. data
  377. }) => {
  378. if (data.code == 0) {
  379. this.tableDataLoading = false
  380. let returnData = data.data
  381. this.yijiData = returnData.records
  382. // this.erjiTypr = false
  383. if (this.title == '修改') {
  384. this.classSelectErT()
  385. }
  386. } else {
  387. this.$notify({
  388. title: '提示',
  389. duration: 1800,
  390. message: data.msg,
  391. type: 'warning'
  392. });
  393. }
  394. })
  395. },
  396. // 获取二级岗位数据
  397. classSelectErT() {
  398. this.$http({
  399. url: this.$http.adornUrl('admin/rule/adminGetParentId'),
  400. method: 'get',
  401. params: this.$http.adornParams({
  402. 'parentId': this.yijiid,
  403. 'industryName': '',
  404. })
  405. }).then(({
  406. data
  407. }) => {
  408. if (data.code == 0) {
  409. this.tableDataLoading = false
  410. let returnData = data.data
  411. this.erjiData = returnData.records
  412. } else {
  413. this.$notify({
  414. title: '提示',
  415. duration: 1800,
  416. message: data.msg,
  417. type: 'warning'
  418. });
  419. }
  420. })
  421. },
  422. // 选择一级岗位分类
  423. yijiBtn(yijiid) {
  424. this.erjiId = ''
  425. this.sanjiTypr = ''
  426. this.classSelectErT()
  427. },
  428. // 选择二级岗位分类
  429. erjiBtn(erjiId) {
  430. this.sanjiTypr = ''
  431. for (var i in this.erjiData) {
  432. if (this.erjiId == this.erjiData[i].ruleClassifyId) {
  433. if (this.erjiData[i].childrens) {
  434. this.sanjiData = this.erjiData[i].childrens
  435. } else {
  436. this.sanjiData = []
  437. }
  438. }
  439. }
  440. },
  441. // 启用与否
  442. change(id, isEnable,row) {
  443. this.$http({
  444. url: this.$http.adornUrl('postSkill/updatePostSkill'),
  445. method: 'post',
  446. // data: this.$http.adornData({
  447. params: this.$http.adornParams({
  448. 'isEnable': isEnable,
  449. 'sort':row.sort,
  450. 'postSkillId': row.postSkillId,
  451. 'postSkillName': row.postSkillName,
  452. 'ruleClassifyId': row.ruleClassifyId,
  453. 'parentId': row.parentId
  454. })
  455. }).then(({
  456. data
  457. }) => {
  458. if(data.code==0){
  459. this.$message({
  460. message: '操作成功',
  461. type: 'success',
  462. duration: 1500,
  463. onClose: () => {
  464. if(row.parentId==0){
  465. this.classSelect()
  466. }else{
  467. this.stationClass()
  468. }
  469. }
  470. })
  471. }else{
  472. this.$message({
  473. message: data.msg,
  474. type: 'warning',
  475. duration: 1500,
  476. onClose: () => {
  477. if(row.parentId==0){
  478. this.classSelect()
  479. }else{
  480. this.stationClass()
  481. // this.stationClass2()
  482. }
  483. }
  484. })
  485. }
  486. })
  487. },
  488. // 提交修改、添加服务分类
  489. refuseto1() {
  490. if (this.postSkillName == '' && this.parentId==0) {
  491. this.$notify({
  492. title: '提示',
  493. duration: 1800,
  494. message: '请输入职业方向名称',
  495. type: 'warning'
  496. })
  497. return
  498. }
  499. if (this.sanjiTypr == '') {
  500. this.$notify({
  501. title: '提示',
  502. duration: 1800,
  503. message: '请选择所属岗位',
  504. type: 'warning'
  505. });
  506. return
  507. }
  508. if (this.postSkillName == '' && this.parentId!=0) {
  509. this.$notify({
  510. title: '提示',
  511. duration: 1800,
  512. message: '请输入职业技能名称',
  513. type: 'warning'
  514. })
  515. return
  516. }
  517. if (this.sort === '') {
  518. this.$notify({
  519. title: '提示',
  520. duration: 1800,
  521. message: '请选择排序',
  522. type: 'warning'
  523. })
  524. return
  525. }
  526. if (this.titles == '添加职业方向' || this.titles == '添加职业技能') {
  527. var urls = 'postSkill/addPostSkill'
  528. } else {
  529. var urls = 'postSkill/updatePostSkill'
  530. }
  531. this.$http({
  532. url: this.$http.adornUrl(urls),
  533. method: 'post',
  534. params: this.$http.adornParams({
  535. 'isEnable': this.gameStatus,
  536. 'sort': this.sort,
  537. 'ruleClassifyId': this.sanjiTypr,
  538. 'parentId':this.parentId,
  539. 'postSkillName': this.postSkillName,
  540. 'postSkillId': this.postSkillId
  541. })
  542. }).then(({
  543. data
  544. }) => {
  545. if(data.code==0){
  546. this.dialogFormVisible9 = false
  547. this.$message({
  548. message: '操作成功',
  549. type: 'success',
  550. duration: 1500,
  551. onClose: () => {
  552. if(this.parentId==0){
  553. this.classSelect()
  554. }else{
  555. this.stationClass()
  556. }
  557. }
  558. })
  559. }else{
  560. this.$message({
  561. message: data.msg,
  562. type: 'warning',
  563. duration: 1500,
  564. onClose: () => {
  565. }
  566. })
  567. }
  568. })
  569. },
  570. // 删除分类
  571. classdelete(row) {
  572. this.$confirm(`确定删除此条信息?`, '提示', {
  573. confirmButtonText: '确定',
  574. cancelButtonText: '取消',
  575. type: 'warning'
  576. }).then(() => {
  577. this.$http({
  578. url: this.$http.adornUrl('postSkill/deletePostSkill'),
  579. method: 'get',
  580. params: this.$http.adornParams({
  581. 'postSkillId': row.postSkillId
  582. })
  583. }).then(({
  584. data
  585. }) => {
  586. if(data.code==0){
  587. this.$message({
  588. message: '删除成功',
  589. type: 'success',
  590. duration: 1500,
  591. onClose: () => {
  592. this.classSelect()
  593. // this.dialogVisibleS = false
  594. }
  595. })
  596. }else{
  597. this.$message({
  598. message: data.msg,
  599. type: 'warning',
  600. duration: 1500,
  601. onClose: () => {
  602. }
  603. })
  604. }
  605. })
  606. }).catch(() => {})
  607. },
  608. // 岗位列表
  609. classList(row,index){
  610. if(index==2){
  611. this.postSkillIdT = row.postSkillId
  612. this.stationClass()
  613. this.dialogVisible = true
  614. }
  615. },
  616. stationlick(){
  617. this.page1 = 1
  618. this.stationClass()
  619. },
  620. // 获取岗位列表
  621. stationClass() {
  622. this.tableDataLoading4 = true
  623. this.$http({
  624. url: this.$http.adornUrl('postSkill/selectPostSkillList'),
  625. method: 'get',
  626. params: this.$http.adornParams({
  627. 'page': this.page1,
  628. 'limit': this.size1,
  629. 'parentId': this.postSkillIdT
  630. })
  631. }).then(({
  632. data
  633. }) => {
  634. this.tableDataLoading4 = false
  635. for(var i in data.data.records){
  636. data.data.records[i].flname = ''
  637. }
  638. let returnData = data.data
  639. this.stationList = returnData
  640. })
  641. },
  642. // 删除岗位
  643. stationDelete(row){
  644. this.$confirm(`确定删除此条信息?`, '提示', {
  645. confirmButtonText: '确定',
  646. cancelButtonText: '取消',
  647. type: 'warning'
  648. }).then(() => {
  649. this.$http({
  650. url: this.$http.adornUrl('postSkill/deletePostSkill'),
  651. method: 'get',
  652. params: this.$http.adornParams({
  653. 'postSkillId': row.postSkillId
  654. })
  655. }).then(({
  656. data
  657. }) => {
  658. if(data.code==0){
  659. this.$message({
  660. message: '删除成功',
  661. type: 'success',
  662. duration: 1500,
  663. onClose: () => {
  664. this.stationClass()
  665. // this.stationClass2()
  666. // this.dialogVisibleS = false
  667. }
  668. })
  669. }else{
  670. this.$message({
  671. message: data.msg,
  672. type: 'warning',
  673. duration: 1500,
  674. onClose: () => {
  675. }
  676. })
  677. }
  678. })
  679. }).catch(() => {})
  680. },
  681. // 文件选择/改变时触发
  682. handleFileChange(file, fileList) {
  683. this.fileList = fileList
  684. // 校验文件类型和大小
  685. const isExcel = file.raw.type === 'application/vnd.ms-excel' ||
  686. file.raw.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  687. const isLt10M = file.raw.size / 1024 / 1024 < 10
  688. if (!isExcel) {
  689. this.$message.error('仅支持上传.xls/.xlsx格式的Excel文件!')
  690. this.fileList = [] // 清空文件列表
  691. return
  692. }
  693. if (!isLt10M) {
  694. this.$message.error('上传文件大小不能超过10MB!')
  695. this.fileList = [] // 清空文件列表
  696. return
  697. }
  698. },
  699. // 移除文件时触发
  700. handleFileRemove() {
  701. this.fileList = []
  702. },
  703. // 确认导入
  704. async handleImport() {
  705. try {
  706. this.$loading({ text: '正在导入数据,请稍候...' })
  707. // 获取选中的文件
  708. const file = this.fileList[0].raw
  709. // 调用导入接口
  710. // const res = await importExcel(file)
  711. const formData = new FormData()
  712. formData.append('file', file)
  713. this.$http({
  714. url: this.$http.adornUrl('admin/rule/import'),
  715. method: 'post',
  716. data: formData
  717. }).then(({
  718. data
  719. }) => {
  720. if(data.code==0){
  721. this.$message({
  722. message: '删除成功',
  723. type: 'success',
  724. duration: 1500,
  725. onClose: () => {
  726. this.stationClass()
  727. // this.stationClass2()
  728. // this.dialogVisibleS = false
  729. }
  730. })
  731. }
  732. })
  733. this.$loading().close()
  734. // this.$message.success(res.msg || '导入成功!')
  735. // 清空文件列表
  736. this.fileList = []
  737. // 可选:刷新页面数据
  738. // this.$emit('refreshData')
  739. } catch (error) {
  740. this.$loading().close()
  741. this.$message.error('导入失败:' + (error.message || '服务器异常'))
  742. this.fileList = []
  743. }
  744. },
  745. // importExcel(file) {
  746. // const formData = new FormData()
  747. // formData.append('file', file) // 注意:key必须和后端@RequestParam("file")一致
  748. // return request({
  749. // url: '/admin/rule/import', // 后端接口路径
  750. // method: 'post',
  751. // data: formData,
  752. // // 文件上传需设置Content-Type为multipart/form-data(axios会自动处理,无需手动设置)
  753. // headers: {
  754. // 'Content-Type': 'multipart/form-data'
  755. // }
  756. // })
  757. // }
  758. },
  759. mounted() {
  760. this.classSelect()
  761. },
  762. }
  763. </script>
  764. <style>
  765. .customWidth {
  766. width: 80% !important;
  767. }
  768. .adver_main.box {
  769. display: block;
  770. max-width: 100%;
  771. text-align: center;
  772. border: 1px dotted rgba(67, 79, 103, .4);
  773. }
  774. .cards {
  775. padding: 0 8px;
  776. margin-bottom: 15px;
  777. }
  778. .adver_main.box a {
  779. display: flex;
  780. justify-content: center;
  781. height: 150px;
  782. line-height: 150px;
  783. text-decoration: none
  784. }
  785. .bannerManin {
  786. border: 1px solid #e8e8e8;
  787. font-size: 14px;
  788. padding: 0 24px;
  789. display: flex;
  790. justify-content: center;
  791. align-items: center;
  792. height: 113px;
  793. color: rgba(0, 0, 0, .65);
  794. }
  795. .bannerManin span {
  796. display: inline-block;
  797. margin-left: 5px;
  798. }
  799. .bannerManin img {
  800. width: 48px;
  801. height: 48px;
  802. border-radius: 50%;
  803. }
  804. .bannerbtn {
  805. display: flex;
  806. border-top: none !important;
  807. border: 1px solid #e8e8e8;
  808. padding: 11px;
  809. font-size: 14px;
  810. color: #3E8EF7;
  811. }
  812. .bannerbtn a {
  813. flex: 1;
  814. text-align: center;
  815. color: #3E8EF7 !important;
  816. text-decoration: none;
  817. }
  818. .imgs {
  819. position: relative;
  820. border-radius: 6px;
  821. width: 148px;
  822. height: 148px;
  823. margin-right: 10px;
  824. display: inline-block;
  825. }
  826. .dels {
  827. position: absolute;
  828. top: 0;
  829. left: 0;
  830. display: none;
  831. }
  832. .dels .el-icon-delete {
  833. line-height: 148px;
  834. padding-left: 58px;
  835. font-size: 25px;
  836. color: #fff;
  837. }
  838. .imgs:hover .dels {
  839. width: 100%;
  840. height: 100%;
  841. background: #000;
  842. display: block;
  843. opacity: 0.5;
  844. }
  845. .bqList {
  846. padding: 4px 14px;
  847. margin: 4px;
  848. border: 1px solid #efefef;
  849. font-size: 12px;
  850. color: #999;
  851. border-radius: 4px;
  852. margin-right: 15px;
  853. }
  854. .delss {
  855. display: none;
  856. position: relative;
  857. }
  858. .delss .el-icon-delete {
  859. position: absolute;
  860. top: 0;
  861. }
  862. .bqList:hover .delss {
  863. display: initial;
  864. opacity: 0.5;
  865. }
  866. .tj {
  867. padding: 6px !important;
  868. margin: 4px;
  869. font-size: 12px;
  870. border: 1px solid #ccc;
  871. border-radius: 4px;
  872. }
  873. </style>