mailList.vue 8.7 KB

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