handlePerson.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div>
  3. <el-dialog title="配案人员" :visible.sync="visible" width="800px" :close-on-click-modal="false" :before-close="handleClose" append-to-body>
  4. <div style="height:calc(100vh - 250px)">
  5. <div class="header">
  6. <el-button type="primary" size="small" @click="add">添加</el-button>
  7. </div>
  8. <el-table
  9. ref="table"
  10. border
  11. :data="tableData"
  12. row-key="id"
  13. style="width: 100%"
  14. height="calc(100% - 50px)"
  15. v-loading="loading">
  16. <el-table-column prop="name" label="姓名" min-width="220">
  17. <template slot-scope="scope">
  18. <div>
  19. <div v-if="scope.row.id && editMessage.id!=scope.row.id">
  20. {{ scope.row.name }}
  21. </div>
  22. <div v-else>
  23. <el-autocomplete
  24. style="width: 100%;"
  25. class="inline-input"
  26. v-model="scope.row.name"
  27. v-SelectLazyLoading="IPREmailLoad"
  28. :fetch-suggestions="querySearchByName"
  29. placeholder="请输入内容"
  30. @select="(item)=>handleSelect(item,scope.row)"
  31. >
  32. <template slot-scope="{ item }">
  33. <div style="padding: 5px 0;">
  34. <div style="text-overflow: ellipsis;overflow: hidden;line-height: normal;">{{ item.name }}</div>
  35. <div style="font-size: 12px;color: #b4b4b4;line-height: normal;">{{ item.email }}</div>
  36. </div>
  37. </template>
  38. </el-autocomplete>
  39. </div>
  40. </div>
  41. </template>
  42. </el-table-column>
  43. <el-table-column prop="email" label="邮箱" min-width="220">
  44. <template slot-scope="scope">
  45. <div>
  46. <div v-if="scope.row.id && editMessage.id!=scope.row.id">
  47. {{ scope.row.email }}
  48. </div>
  49. <div v-else>
  50. <el-autocomplete
  51. style="width: 100%;"
  52. class="inline-input"
  53. v-model="scope.row.email"
  54. v-SelectLazyLoading="IPREmailLoad"
  55. :fetch-suggestions="querySearchByEmail"
  56. placeholder="请输入内容"
  57. @select="(item)=>handleSelect(item,scope.row)"
  58. >
  59. <template slot-scope="{ item }">
  60. <div style="padding: 5px 0;">
  61. <div style="text-overflow: ellipsis;overflow: hidden;line-height: normal;">{{ item.email }}</div>
  62. <div style="font-size: 12px;color: #b4b4b4;line-height: normal;">{{ item.name }}</div>
  63. </div>
  64. </template>
  65. </el-autocomplete>
  66. </div>
  67. </div>
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="操作" width="180px">
  71. <template slot-scope="scope">
  72. <div>
  73. <div v-if="scope.row.id && editMessage.id!=scope.row.id">
  74. <el-button type="text" size="small" @click="edit(scope.row)">修改</el-button>
  75. <el-button type="text" size="small" @click="remove(scope.row)">移除</el-button>
  76. </div>
  77. <div v-else>
  78. <el-button type="text" size="small" @click="save(scope.row)">保存</el-button>
  79. <el-button type="text" size="small" @click="cancel(scope.row,scope.$index)">取消</el-button>
  80. </div>
  81. </div>
  82. </template>
  83. </el-table-column>
  84. </el-table>
  85. </div>
  86. </el-dialog>
  87. </div>
  88. </template>
  89. <script>
  90. export default {
  91. components: {
  92. },
  93. props: {},
  94. data() {
  95. return {
  96. visible:false,
  97. tableData:[],
  98. loading:false,
  99. model:'list',
  100. IPREmailList:{
  101. queryParams:{
  102. current:0,
  103. size:10,
  104. total:1,
  105. name:null,
  106. email:null
  107. },
  108. data:[]
  109. },
  110. editMessage:{},
  111. reportId:null
  112. };
  113. },
  114. watch: {},
  115. computed: {},
  116. created() {},
  117. mounted() {},
  118. methods: {
  119. open(reportId){
  120. this.reportId =reportId
  121. this.editMessage = {}
  122. this.getList()
  123. this.visible = true
  124. },
  125. getList(){
  126. var params = {
  127. reportId:this.reportId
  128. }
  129. this.model = 'list'
  130. this.loading = true
  131. var api = 'matchCasePersonQuery'
  132. this.$api[api](params).then(response=>{
  133. if(response.code == 200){
  134. this.tableData = response.data
  135. this.loading = false
  136. }
  137. }).catch(error=>{
  138. this.tableData = []
  139. this.loading = false
  140. })
  141. },
  142. handleClose(){
  143. this.visible = false
  144. },
  145. //添加
  146. add(){
  147. this.tableData.push({})
  148. this.model = 'add'
  149. },
  150. //编辑
  151. edit(row){
  152. if(this.model != 'list' ){
  153. this.$message.warning('已有数据正在编辑,请先保存修改的数据')
  154. return
  155. }
  156. this.model = 'edit'
  157. this.editMessage = JSON.parse(JSON.stringify(row))
  158. },
  159. //移除配案人员
  160. remove(row){
  161. this.$confirm('确认删除选择的数据吗?', '提示', {
  162. confirmButtonText: '确定',
  163. cancelButtonText: '取消',
  164. type: 'warning'
  165. }).then(() => {
  166. this.loading = true
  167. this.$api.matchCasePersonDelete([row.id]).then(response => {
  168. this.$message.success('移除成功')
  169. this.loading = false
  170. this.getList()
  171. this.IPREmailList={
  172. queryParams:{
  173. current:0,
  174. size:10,
  175. total:1,
  176. name:null,
  177. email:null
  178. },
  179. data:[]
  180. }
  181. }).catch(error => {
  182. this.loading = false
  183. })
  184. })
  185. },
  186. //取消编辑
  187. cancel(row,index){
  188. if(this.model == 'add'){
  189. this.tableData.splice(index,1)
  190. return
  191. }else{
  192. row = JSON.parse(JSON.stringify(this.editMessage))
  193. this.editMessage = {}
  194. }
  195. this.model = 'list'
  196. },
  197. //保存
  198. save(row){
  199. if(!row.name){
  200. this.$message.warning('姓名不能为空')
  201. return
  202. }
  203. if(!row.email){
  204. this.$message.warning('邮箱不能为空')
  205. return
  206. }
  207. var regx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9_\.\-])+\.)+([a-zA-Z0-9]{2,4})+$/
  208. if(!regx.test(row.email)){
  209. this.$message.warning('邮箱格式不正确')
  210. return
  211. }
  212. var a = '添加'
  213. if(row.id){
  214. a = '修改'
  215. }
  216. this.loading = true
  217. row.reportId = this.reportId
  218. this.$api.matchCasePersonUpdate(row).then(response=>{
  219. if(response.code == 200){
  220. this.$message.success(a+'成功')
  221. this.loading = false
  222. this.getList()
  223. }
  224. }).catch(error=>{
  225. this.loading = false
  226. })
  227. },
  228. /**
  229. * IPR邮箱
  230. */
  231. // 懒加载IPR邮箱方法
  232. IPREmailLoad() {
  233. if (this.IPREmailList.queryParams.current * this.IPREmailList.queryParams.size >= this.IPREmailList.queryParams.total) {
  234. return false
  235. }
  236. this.IPREmailList.queryParams.current++
  237. this.getIPREmailList()
  238. },
  239. // 查询IPR邮箱
  240. async getIPREmailList() {
  241. let params = {
  242. ...this.IPREmailList.queryParams,
  243. }
  244. await this.$api.iprPersonQuery(params).then(res => {
  245. if (res.code == 200) {
  246. this.IPREmailList.data.push(...res.data.data)
  247. this.IPREmailList.queryParams.total = res.data.total
  248. this.IPREmailList.cb(this.IPREmailList.data);
  249. }
  250. })
  251. },
  252. //获取下拉建议IPR邮箱数据
  253. async querySearchByEmail(queryString, cb) {
  254. this.IPREmailList.queryParams.current = 1
  255. this.IPREmailList.queryParams.email = queryString
  256. this.IPREmailList.data = []
  257. this.IPREmailList.cb = cb
  258. await this.getIPREmailList()
  259. },
  260. async querySearchByName(queryString, cb) {
  261. this.IPREmailList.queryParams.current = 1
  262. this.IPREmailList.queryParams.name = queryString
  263. this.IPREmailList.data = []
  264. this.IPREmailList.cb = cb
  265. await this.getIPREmailList()
  266. },
  267. handleSelect(item,row){
  268. this.$set(row,'name',item.name)
  269. this.$set(row,'email',item.email)
  270. this.$set(row,'iprPersonId',item.id)
  271. }
  272. },
  273. };
  274. </script>
  275. <style lang="scss" scoped>
  276. .header{
  277. height: 50px;
  278. display: flex;
  279. flex-direction: row-reverse;
  280. align-items: center;
  281. }
  282. </style>