changeRecord.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <div>
  3. <el-drawer :title="recordData.name + ' 变更记录'" append-to-body :visible.sync="visible" direction="rtl"
  4. :before-close="recordClose" custom-class="custom">
  5. <div class="cut">
  6. <el-button class="button" type="primary" icon="el-icon-plus" size="mini"
  7. @click="handleCutRecord">插入起始记录</el-button>
  8. <el-table :data="recordList" size="mini" :lazy="true">
  9. <el-table-column label="开始时间" prop="beginTime" align="center" width="90" />
  10. <el-table-column label="结束时间" prop="endTime" align="center" width="90" />
  11. <el-table-column label="企业号ID" prop="corpUserId" align="center" :show-overflow-tooltip="true"
  12. width="120" />
  13. <el-table-column label="企微ID" prop="corpId" :show-overflow-tooltip="true" width="300" />
  14. <el-table-column label="运营" prop="operUserId" align="center" width="100">
  15. <template slot-scope="scope">
  16. <div>{{ scope.row.operUserId ? scope.row.operUser.nickName : '--' }}</div>
  17. </template>
  18. </el-table-column>
  19. <el-table-column label="投手" prop="putUserId" align="center" width="100">
  20. <template slot-scope="scope">
  21. <div>{{ scope.row.putUserId ? scope.row.putUser.nickName : '--' }}</div>
  22. </template>
  23. </el-table-column>
  24. <el-table-column label="操作" align="center" fixed="right"
  25. width="150">
  26. <template slot-scope="scope">
  27. <div>
  28. <el-button type="text" @click="insertDownHandle(scope.row, '向后插入')"
  29. size="mini">往后插入</el-button>
  30. <el-button type="text" @click="insertDownHandle(scope.row, '修改')" size="mini">修改</el-button>
  31. <el-button type="text" style="color: red" size="mini"
  32. @click="delRecordHandle(scope.row)">删除</el-button>
  33. </div>
  34. </template>
  35. </el-table-column>
  36. </el-table>
  37. </div>
  38. </el-drawer>
  39. <!-- 新增 编辑记录弹窗 -->
  40. <el-dialog :title="title" :visible.sync="editShow" width="360px" append-to-body @close="editShow = false">
  41. <el-form :model="queryPlatformRecord" :rules="rules" ref="platFormRecord" label-width="80px">
  42. <el-form-item label="开始时间" prop="beginTime">
  43. <el-date-picker v-model="queryPlatformRecord.beginTime" size="small" format="yyyy-MM-dd"
  44. value-format="yyyy-MM-dd" type="date" placeholder="选择开始时间" />
  45. </el-form-item>
  46. <el-form-item label="结束时间" prop="endTime">
  47. <el-date-picker v-model="queryPlatformRecord.endTime" size="small" format="yyyy-MM-dd"
  48. value-format="yyyy-MM-dd" type="date" placeholder="选择开始时间" />
  49. </el-form-item>
  50. <el-form-item label="运营" prop="operUserId">
  51. <el-select v-model="queryPlatformRecord.operUserId" size="small" placeholder="选择运营" filterable
  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="queryPlatformRecord.putUserId" size="small" placeholder="选择投手" filterable 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>
  62. <span slot="footer" class="dialog-footer">
  63. <el-button @click="editShow = false; queryPlatformRecord = {}">取 消</el-button>
  64. <el-button type="primary" @click="submitRecord('platFormRecord')">确 定</el-button>
  65. </span>
  66. </el-dialog>
  67. </div>
  68. </template>
  69. <script>
  70. import { getAllOfCorpList, addAllOfCorp, putAllOfCorp, delAllOfCorp } from "@/api/accounts/corpWeChat";
  71. export default {
  72. data() {
  73. return {
  74. recordList: [],
  75. loading: false,
  76. title: '',
  77. editShow: false,
  78. queryPlatformRecord: {},
  79. rules: {
  80. beginTime: [
  81. { required: true, message: '请选择开始时间', trigger: 'change' }
  82. ]
  83. }
  84. }
  85. },
  86. props: {
  87. recordData: {
  88. type: Object,
  89. default: {},
  90. },
  91. visible: {
  92. type: Boolean,
  93. default: false
  94. },
  95. userAll: {
  96. type: Array,
  97. default: []
  98. }
  99. },
  100. watch: {
  101. visible: {
  102. handler(val) {
  103. if (val) {
  104. this.$nextTick(() => {
  105. this.getList()
  106. })
  107. }
  108. },
  109. immediate: true,
  110. },
  111. },
  112. methods: {
  113. submitRecord(formName) {
  114. this.$refs[formName].validate((valid) => {
  115. if (valid) {
  116. let params = JSON.parse(JSON.stringify(this.queryPlatformRecord))
  117. if(params.beginTime) {
  118. params.beginTime = params.beginTime
  119. }
  120. if(params.endTime) {
  121. params.endTime = params.endTime
  122. }
  123. if(!params.id) { // 新增
  124. addAllOfCorp(params).then(res => {
  125. this.msgSuccess("插入成功");
  126. this.resetForm(formName);
  127. this.editShow = false
  128. this.getList()
  129. })
  130. } else { // 修改
  131. let { id, ...data } = params
  132. putAllOfCorp({ recordId: id, ...data }).then(res => {
  133. this.msgSuccess("修改成功");
  134. this.resetForm(formName);
  135. this.editShow = false
  136. this.getList()
  137. })
  138. }
  139. }
  140. })
  141. },
  142. handleCutRecord() {
  143. const { id, putUserId, operUserId, corpId, corpUserId } = this.recordData
  144. this.title = '插入起始记录'
  145. this.editShow = true
  146. this.queryPlatformRecord = {
  147. resourceId: id,
  148. operUserId,
  149. putUserId,
  150. corpId,
  151. corpUserId
  152. }
  153. },
  154. /** 修改插入 */
  155. insertDownHandle(item, type) {
  156. this.title = `${type}记录`
  157. this.editShow = true
  158. let data = {}
  159. if (item.beginTime) {
  160. item.beginTime = item.beginTime.split(' ')[0]
  161. }
  162. if (item.endTime) {
  163. item.endTime = item.endTime.split(' ')[0]
  164. }
  165. const { beginTime, endTime, id, operUserId, putUserId, corpId, corpUserId } = item
  166. if (type === '修改') {
  167. data = { beginTime, endTime, id }
  168. } else {
  169. data = { nextId: id, corpId, corpUserId }
  170. }
  171. this.queryPlatformRecord = {
  172. ...data,
  173. operUserId,
  174. putUserId,
  175. }
  176. },
  177. /** 删除 */
  178. delRecordHandle(row) {
  179. this.$confirm('确定删除?', '删除', {
  180. distinguishCancelAndClose: true,
  181. confirmButtonText: '确定',
  182. cancelButtonText: '取消'
  183. }).then(() => {
  184. delAllOfCorp(row.id).then(res => {
  185. if (res.data) {
  186. this.msgSuccess('删除成功');
  187. this.getList()
  188. }
  189. })
  190. })
  191. },
  192. getList() {
  193. this.loading = true
  194. getAllOfCorpList(this.recordData.corpId, this.recordData.corpUserId).then(res => {
  195. if (res) {
  196. this.recordList = res.data
  197. }
  198. this.loading = false
  199. }).catch(() => this.loading = false)
  200. },
  201. // 关闭
  202. recordClose() {
  203. this.$emit("close");
  204. }
  205. }
  206. }
  207. </script>
  208. <style lang="scss">
  209. .custom {
  210. width: 55% !important;
  211. }
  212. .cut {
  213. padding: 0 10px;
  214. box-sizing: border-box;
  215. .button {
  216. margin-bottom: 10px;
  217. }
  218. .el-table .cell {
  219. line-height: normal;
  220. }
  221. ul {
  222. padding-left: 0;
  223. .sumitInfo {
  224. // margin-top: 20px;
  225. font-weight: 600;
  226. margin-bottom: 10px;
  227. .button {
  228. margin-left: 20px;
  229. }
  230. }
  231. }
  232. }
  233. </style>