IPREmail.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <div class="height_100">
  3. <el-container>
  4. <el-header>
  5. <div class="head">
  6. <div>
  7. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" >
  8. <el-form-item label="姓名:" prop="name" >
  9. <el-input v-model="queryParams.name" placeholder="请输入姓名"></el-input>
  10. </el-form-item>
  11. <el-form-item label="邮箱:" prop="email">
  12. <el-input v-model="queryParams.email" placeholder="请输入邮箱"></el-input>
  13. </el-form-item>
  14. <el-form-item label="类型:" prop="ifDefault">
  15. <el-select v-model="queryParams.ifDefault" placeholder="请选择" clearable >
  16. <el-option v-for="(item, key) in types" :key="key" :label="item" :value="key"></el-option>
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item>
  20. <el-button type="primary" icon="el-icon-search" size="mini" @click="search">搜索</el-button>
  21. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  22. </el-form-item>
  23. </el-form>
  24. </div>
  25. <div>
  26. <el-button icon="el-icon-plus" size="mini" @click="add">新增</el-button>
  27. </div>
  28. </div>
  29. </el-header>
  30. <el-main>
  31. <IPREmailTable :tableData="tableData" :loading="loading">
  32. <template slot="column">
  33. <el-table-column label="操作" align="center" width="120px">
  34. <template slot-scope="scope">
  35. <div v-if="userinfo.roleType==1 || userinfo.roleType == 2 || userinfo.id == scope.row.createId">
  36. <el-button type="text" size="small" @click="edit(scope.row)">编辑</el-button>
  37. <el-button type="text" size="small" @click="remove(scope.row)">删除</el-button>
  38. </div>
  39. </template>
  40. </el-table-column>
  41. </template>
  42. </IPREmailTable>
  43. </el-main>
  44. <el-footer class="pagination">
  45. <el-pagination background layout="total, sizes, prev, pager, next, jumper"
  46. :current-page.sync="queryParams.current" :page-size.sync="queryParams.size"
  47. @current-change="handleCurrentChange" @size-change="changeSize" :total="total">
  48. </el-pagination>
  49. </el-footer>
  50. </el-container>
  51. <!-- 新增或者编辑IPR邮箱 -->
  52. <addOrEditIPREmailDialog ref="addOrEditIPREmailDialog" @close="closeAddOrEditIPREmail"></addOrEditIPREmailDialog>
  53. </div>
  54. </template>
  55. <script>
  56. const defaultSearchForm={
  57. name:null,
  58. email:null,
  59. ifDefault:null
  60. }
  61. import IPREmailTable from '../table/IPREmail.vue'
  62. import addOrEditIPREmailDialog from './components/dialog/addOrEditIPREmail.vue';
  63. export default {
  64. components: {
  65. IPREmailTable,
  66. addOrEditIPREmailDialog
  67. },
  68. props: {
  69. type:{
  70. type:[String,Number],
  71. default:"1"
  72. }
  73. },
  74. data() {
  75. return {
  76. tableData:[],
  77. queryParams:{
  78. current:1,
  79. size:10,
  80. type:this.type,
  81. ...defaultSearchForm,
  82. },
  83. total:0,
  84. loading:false,
  85. types:{
  86. true:'默认发送邮箱',
  87. false:'非默认发送邮箱'
  88. }
  89. };
  90. },
  91. watch: {
  92. type(){
  93. this.queryParams.type = this.type
  94. this.handleCurrentChange(1)
  95. },
  96. },
  97. computed: {
  98. userinfo(){
  99. return this.$s.getObj('userinfo')
  100. },
  101. },
  102. created() {},
  103. mounted() {
  104. this.getList()
  105. },
  106. methods: {
  107. async getList(){
  108. this.loading = true
  109. var api = 'iprPersonQuery'
  110. this.$api[api](this.queryParams).then(response=>{
  111. if(response.code == 200){
  112. this.tableData = response.data.data
  113. this.total = response.data.total
  114. this.loading = false
  115. }
  116. }).catch(error=>{
  117. this.tableData = []
  118. this.total = 0
  119. this.loading = false
  120. })
  121. },
  122. //切换分页
  123. handleCurrentChange(value){
  124. this.queryParams.current = value
  125. this.getList()
  126. },
  127. //切换页大小
  128. changeSize(value){
  129. this.queryParams.size = value
  130. this.queryParams.current = 1
  131. this.getList()
  132. },
  133. //检索
  134. search(){
  135. this.queryParams.current = 1
  136. this.getList()
  137. },
  138. //重置条件
  139. resetQuery(){
  140. this.queryParams = {
  141. ...this.queryParams,
  142. ...defaultSearchForm
  143. }
  144. this.search()
  145. },
  146. //添加IPR邮箱
  147. add(){
  148. let form = {
  149. type:this.type
  150. }
  151. this.$refs.addOrEditIPREmailDialog.open(form,'add')
  152. },
  153. //编辑IPR邮箱
  154. edit(row){
  155. this.$refs.addOrEditIPREmailDialog.open(row,'edit')
  156. },
  157. //回调
  158. closeAddOrEditIPREmail(model){
  159. if(model == 'add'){
  160. this.search()
  161. }
  162. if(model == 'edit'){
  163. this.getList()
  164. }
  165. },
  166. //删除
  167. remove(row){
  168. this.$confirm('确认删除选择的数据吗?', '提示', {
  169. confirmButtonText: '确定',
  170. cancelButtonText: '取消',
  171. type: 'warning'
  172. }).then(() => {
  173. this.loading = true
  174. this.$api.iprPersonDelete([row.id]).then(response => {
  175. this.$message.success('删除成功')
  176. this.loading = false
  177. this.delFinish()
  178. }).catch(error => {
  179. this.loading = false
  180. })
  181. })
  182. },
  183. delFinish(){
  184. if(this.tableData.length == 1 && this.queryParams.current!=1){
  185. this.queryParams.current -= 1
  186. }
  187. this.getList()
  188. },
  189. },
  190. };
  191. </script>
  192. <style lang="scss" scoped>
  193. .head{
  194. width:100%;
  195. display: flex;
  196. align-items: center;
  197. justify-content: space-between;
  198. }
  199. </style>