https://juejin.im/post/6872128694639394830
vue3.0 ts 知乎
http://docs.vikingship.xyz/
vue3 ts
https://mp.weixin.qq.com/s/fo3_KwiKtRLVs6BUfe3iVg

  1. let url = "/api/privilege/stcommon/getCurrentUser";
  2. const config = {
  3. headers:{
  4. 'Authorization':'Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhcWhiYy5uaiIsImV4cCI6MTYwMTExNTUxMywiaWF0IjoxNjAxMTE1NTEzfQ.Nq1NxfKjFoV_SwJfiFDU6Mrp1KM-Lb30-0pevQm6rg8',
  5. 'Content-Type' : 'application/json; charset=utf-8',
  6. 'token': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhcWhiYy5uaiIsImV4cCI6MTYwMTExNTUxMywiaWF0IjoxNjAxMTE1NTEzfQ.Nq1NxfKjFoV_SwJfiFDU6Mrp1KM-Lb30-0pevQm6rg8'
  7. }
  8. }
  9. this.$axios.get(url,config).then((res)=>{
  10. const data = res.data;
  11. this.$store.commit("wopcStoreModules/pushWopcUserInfo",data)
  12. console.log(res)
  13. }).catch(e=>{
  14. console.log(e)
  15. })
  1. localhost; 127.0.0.1; %ComputerName%;*.cnpc;10.*;11.*;*.cnpc.com.cn;*.petrochina;*.local

vue中,使用element ui的el-dialog echarts出错问题

https://www.cnblogs.com/yanyanliu/p/11729876.html

常用Vue组件

打印 - Print.js
Github:https://github.com/crabbly/Print.js官方文档:http://printjs.crabbly.com打印网页示例(继承样式)打印Json数据示例截屏 - html2canvas
Github:https://github.com/niklasvh/html2canvas官方文档:https://html2canvas.hertzen.com截取网页示例截取指定内容示例打印 + 截屏 实现网页样式不丢失打印
打印原样式网页图片示例复制命令 - vue-clipboard2
Github:https://github.com/Inndy/vue-clipboard2官方文档:https://github.com/Inndy/vue-clipboard2复制文本示例轻量级时间转换工具 - date-fns
Github:https://github.com/date-fns/date-fns官方文档:https://date-fns.org已全局挂载 format 方法示例:2021-05-16拖动组件 - Vue.Draggable
Github:https://github.com/SortableJS/Vue.Draggable官网:https://sortablejs.github.io/Vue.Draggable/

  • A
  • B
  • C

图片懒加载 - vue-lazyload
Github:https://github.com/hilongjw/vue-lazyload官网:http://hilongjw.github.io/vue-lazyload文件保存导出下载 - FileSaver.js
Github:https://github.com/eligrey/FileSaver.js官网:https://github.com/eligrey/FileSaver.js

ElementUI

穿梭框使用

  1. <template>
  2. <div id="app-auth-zsmart">
  3. <el-dialog title="综调中心职位授权" :visible.sync="open" width="1200px" :before-close="handleClose" append-to-body
  4. :close-on-click-modal="false">
  5. <el-transfer v-model="value" :data="listData"
  6. :titles="['未授权', '已授权']"
  7. :props="{
  8. key: 'orgJobId',
  9. label: 'jobName',
  10. disabled: 'disabled'
  11. }"
  12. @change="handleChange"
  13. >
  14. <!-- <span slot-scope="{ option }">{{ option.staffOrgId }} - {{ option.jobName }}</span>-->
  15. <span slot-scope="{ option }"><span style="font-size: 6px;color: red;">{{ option.orgName }}</span>&nbsp;&nbsp;<span style="font-size: 8px;">{{ option.jobName }}</span></span>
  16. </el-transfer>
  17. <div slot="footer" class="dialog-footer">
  18. <el-button type="primary" @click="handleOk" size="mini">确 定</el-button>
  19. <!-- <el-button @click="handleClose" size="mini">取 消</el-button>-->
  20. </div>
  21. </el-dialog>
  22. </div>
  23. </template>
  24. <script>
  25. import { fetchZsMartAuthedJobList, fetchZsMartAuthJobList, updateZsMartUserWithJob } from '@/api/rl/rlAuthZsmartApi'
  26. import _ from 'lodash'
  27. export default {
  28. props: {
  29. open: {
  30. type: Boolean,
  31. default: false
  32. },
  33. userName: {
  34. type: String,
  35. default: ''
  36. }
  37. },
  38. name: 'DialogAuthZsmartNew',
  39. components: {},
  40. data() {
  41. return {
  42. authList:[],
  43. authedList:[],
  44. listData: [],
  45. value: []
  46. }
  47. },
  48. created() {
  49. this.init()
  50. const userId = this.$route.params && this.$route.params.userId
  51. console.log(`userId:${userId}`)
  52. },
  53. methods: {
  54. async init() {
  55. const authData = await fetchZsMartAuthJobList(this.userName);
  56. this.authList = authData.data
  57. const authedData = await fetchZsMartAuthedJobList(this.userName);
  58. this.authedList = authedData.data
  59. this.listData = _.forEach(this.authList,v1=>{
  60. let flag = true
  61. _.forEach(this.authedList,v2=>{
  62. let allJobId = v1.orgId+"_"+v1.jobId;
  63. let singleJobId = v2.orgId+"_"+v2.jobId;
  64. if(allJobId === singleJobId){
  65. flag =false;
  66. this.value.push(v1.orgJobId)
  67. }
  68. })
  69. })
  70. console.log(this.listData)
  71. },
  72. handleOk() {
  73. this.$emit('update:open', false)
  74. this.$emit('change')
  75. },
  76. handleClose() {
  77. this.$emit('update:open', false)
  78. },
  79. // 穿梭框更改事件
  80. async handleChange (value, direction, keyArr) {
  81. //value为左/右的所有数值,direction为方向left or right,keyArr为选中的key
  82. switch (direction) {
  83. //右到左 解绑
  84. case 'left':
  85. // 调用后端api绑定接口
  86. console.log(keyArr)
  87. let delJobList = [];
  88. _.forEach(this.listData,v=>{
  89. _.forEach(keyArr,val=>{
  90. if(v.orgJobId === val){
  91. console.log('匹配项:')
  92. console.log(v)
  93. delJobList.push(v)
  94. }
  95. })
  96. })
  97. console.log('待删除数据:{}')
  98. console.log(delJobList)
  99. const delParam = {
  100. 'addJobList': [],
  101. 'deleteJobList':delJobList,
  102. 'userId': this.$route.params && this.$route.params.userId
  103. }
  104. // 提交数据
  105. await updateZsMartUserWithJob(delParam).then(res => {
  106. this.msgSuccess('操作成功')
  107. }).catch(e => {
  108. this.msgError('操作失败')
  109. })
  110. break
  111. //从左到右 绑定
  112. case 'right':
  113. // 调用后端api解绑接口
  114. let addJobList = [];
  115. _.forEach(this.listData,v=>{
  116. _.forEach(keyArr,val=>{
  117. if(v.orgJobId === val){
  118. console.log('匹配项:')
  119. console.log(v)
  120. addJobList.push(v)
  121. }
  122. })
  123. })
  124. console.log('待新增数据:{}')
  125. console.log(addJobList)
  126. const reqParam = {
  127. 'addJobList': addJobList,
  128. 'deleteJobList': [],
  129. 'userId': this.$route.params && this.$route.params.userId
  130. }
  131. // 提交数据
  132. await updateZsMartUserWithJob(reqParam).then(res => {
  133. this.msgSuccess('操作成功')
  134. }).catch(e => {
  135. this.msgError('操作失败')
  136. })
  137. break
  138. }
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="scss" scoped>
  144. // scss 样式穿透
  145. ::v-deep .el-transfer{
  146. display: flex;
  147. align-items: center;
  148. height: 400px;
  149. .el-transfer-panel{
  150. width: 500px;
  151. }
  152. .el-transfer-panel__list.is-filterable {
  153. height: 400px;
  154. }
  155. .el-transfer__buttons{
  156. display: flex;
  157. flex-direction: column;
  158. align-items: center;
  159. justify-content: center;
  160. .el-button.el-button--primary{
  161. margin-left: 0;
  162. }
  163. }
  164. }
  165. </style>