handlePerson.vue 8.1 KB

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