mailList.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <div>
  3. <el-dialog title="企微通讯录" v-if="visible" :visible.sync="visible" :before-close="beforeClose" width="750px">
  4. <el-row :gutter="10" class="mb8" align="middle">
  5. <el-col :span="1.5">
  6. <el-input v-model="queryParams.name" placeholder="企微号名称" clearable size="small"
  7. style="width: 140px" @keyup.enter.native="getList" />
  8. </el-col>
  9. <el-col :span="1.5"><el-button type="cyan" icon="el-icon-search" size="mini" @click="getList">搜索</el-button></el-col>
  10. <el-col :span="1.5">
  11. <div class="grid-content">
  12. <el-button type="primary" size="mini" @click="syncHandle">同步通讯录</el-button>
  13. </div>
  14. </el-col>
  15. </el-row>
  16. <el-table :data="mailList" v-loading="loading" size="mini">
  17. <el-table-column label="企微号" prop="name" width="120" align="center" />
  18. <el-table-column label="运营" prop="operUserId" align="center" width="100">
  19. <template slot-scope="scope">
  20. <div>{{ scope.row.operUserId ? scope.row.operUser.nickName : '--' }}</div>
  21. </template>
  22. </el-table-column>
  23. <el-table-column label="投手" prop="putUserId" align="center" width="100">
  24. <template slot-scope="scope">
  25. <div>{{ scope.row.putUserId ? scope.row.putUser.nickName : '--' }}</div>
  26. </template>
  27. </el-table-column>
  28. <el-table-column label="状态" prop="status" align="center" width="100">
  29. <template slot-scope="scope">
  30. <div>{{ scope.row.status === 1 ? '已激活' : scope.row.status === 2 ? '已禁用' : scope.row.status === 4 ?
  31. '未激活' : scope.row.status === 5 ? '退出企业' : '--' }}</div>
  32. </template>
  33. </el-table-column>
  34. <el-table-column label="创建时间" prop="createTime" align="center" width="150" />
  35. <el-table-column label="操作" width="150" align="center" class-name="small-padding fixed-width" fixed="right">
  36. <template slot-scope="scope">
  37. <template>
  38. <el-button size="mini" type="text" icon="el-icon-sort"
  39. @click="handlePut(scope.row)">指派</el-button>
  40. <el-button size="mini" type="text" icon="el-icon-tickets"
  41. @click="handleRecord(scope.row)">变更记录</el-button>
  42. </template>
  43. </template>
  44. </el-table-column>
  45. </el-table>
  46. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
  47. :limit.sync="queryParams.pageSize" @pagination="getList" />
  48. </el-dialog>
  49. <el-dialog title="指派" :visible.sync="openSys" width="500px" append-to-body>
  50. <el-form :model="assignUSerData" :rules="rules" ref="platFormSysType" label-width="80px" label-position="top">
  51. <el-form-item label="开始时间" prop="beginTime">
  52. <el-date-picker v-model="assignUSerData.beginTime" type="date" format="yyyy-MM-dd"
  53. value-format="yyyy-MM-dd" placeholder="选择开始时间"></el-date-picker>
  54. </el-form-item>
  55. <el-form-item label="运营" prop="operUserId">
  56. <el-select v-model="assignUSerData.operUserId" placeholder="请选择" filterable style="width: 100%"
  57. clearable>
  58. <el-option v-for="item in userAll" :key="item.id" :label="item.nickName" :value="item.id" />
  59. </el-select>
  60. </el-form-item>
  61. <el-form-item label="投手" prop="putUserId">
  62. <el-select v-model="assignUSerData.putUserId" placeholder="请选择" filterable style="width: 100%"
  63. clearable>
  64. <el-option v-for="item in userAll" :key="item.id" :label="item.nickName" :value="item.id" />
  65. </el-select>
  66. </el-form-item>
  67. </el-form>
  68. <span slot="footer" class="dialog-footer">
  69. <el-button @click="openSys = false; assignUSerData = {}">取 消</el-button>
  70. <el-button type="primary" @click="assignUSerSubmit">确 定</el-button>
  71. </span>
  72. </el-dialog>
  73. <changeRecord :visible="recordShow" :recordData="recordData" :userAll="userAll"
  74. @close="recordShow = false; recordData = {}" />
  75. </div>
  76. </template>
  77. <script>
  78. import { putSyncCorpUser, getCorpMailList, putCorpSysUser } from "@/api/accounts/corpWeChat";
  79. import { allUser } from "@/api/system/user";
  80. import { formatDateYMD } from "@/utils"
  81. import changeRecord from './changeRecord.vue'
  82. export default {
  83. name: 'mailList',
  84. components: { changeRecord },
  85. data() {
  86. return {
  87. queryParams: {
  88. pageNum: 1,
  89. pageSize: 20
  90. },
  91. mailList: [],
  92. loading: false,
  93. total: 0,
  94. openSys: false,
  95. userAll: [], //所有用户
  96. assignUSerData: {},
  97. rules: {
  98. beginTime: [
  99. { required: true, message: '请输入开始时间', trigger: 'blur' }
  100. ],
  101. operUserId: [
  102. { required: true, message: '请选择运营', trigger: 'blur' }
  103. ],
  104. putUserId: [
  105. { required: true, message: '请选择投手', trigger: 'blur' }
  106. ],
  107. },
  108. recordShow: false,
  109. recordData: {}
  110. }
  111. },
  112. props: {
  113. corpId: {
  114. type: String,
  115. default: '',
  116. },
  117. visible: {
  118. type: Boolean,
  119. default: false
  120. }
  121. },
  122. watch: {
  123. visible: {
  124. handler(val) {
  125. if (val) {
  126. this.$nextTick(() => {
  127. this.getList()
  128. this.getAll()
  129. })
  130. }
  131. },
  132. immediate: true,
  133. },
  134. },
  135. methods: {
  136. // 变更记录
  137. handleRecord(row) {
  138. this.recordShow = true
  139. this.recordData = row
  140. },
  141. // 指派
  142. handlePut(row) {
  143. this.openSys = true
  144. this.assignUSerData = {
  145. beginTime: formatDateYMD(new Date()),
  146. operUserId: row.operUserId,
  147. putUserId: row.putUserId,
  148. corpId: this.corpId,
  149. corpUserId: row.corpUserId
  150. }
  151. },
  152. assignUSerSubmit() {
  153. this.$refs['platFormSysType'].validate((valid) => {
  154. if (valid) {
  155. console.log(this.assignUSerData);
  156. const loading = this.$loading({
  157. lock: true,
  158. text: 'Loading',
  159. spinner: 'el-icon-loading',
  160. background: 'rgba(0, 0, 0, 0.7)'
  161. });
  162. putCorpSysUser(this.assignUSerData).then(res => {
  163. if (res.data) {
  164. this.$message({
  165. showClose: true,
  166. message: '指派成功',
  167. type: 'success'
  168. });
  169. this.openSys = false
  170. this.assignUSerData = {}
  171. this.getList()
  172. }
  173. loading.close()
  174. }).catch(() => loading.close())
  175. }
  176. })
  177. },
  178. getAll() {
  179. // 所有用户
  180. allUser().then((response) => {
  181. let data = response.data;
  182. this.userAll = data.map((item) => {
  183. return { id: item.userId, nickName: item.nickname };
  184. });
  185. });
  186. },
  187. beforeClose() {
  188. this.$emit("close");
  189. },
  190. syncHandle() {
  191. const loading = this.$loading({
  192. lock: true,
  193. text: 'Loading',
  194. spinner: 'el-icon-loading',
  195. background: 'rgba(0, 0, 0, 0.7)'
  196. });
  197. putSyncCorpUser(this.corpId).then(res => {
  198. this.msgSuccess("同步成功");
  199. loading.close()
  200. this.getList()
  201. }).catch(() => loading.close())
  202. },
  203. getList() {
  204. this.loading = true
  205. getCorpMailList({ corpId: this.corpId, ...this.queryParams }).then(res => {
  206. this.mailList = res.data.records
  207. this.total = res.data.total
  208. this.loading = false
  209. }).catch(() => this.loading = false)
  210. },
  211. onClose() {
  212. this.visible = false
  213. }
  214. }
  215. }
  216. </script>