addPersonal.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <div>
  3. <el-button type="text" class="inline" style="font-size: 12px;" @click="onShow">人员编辑</el-button>
  4. <el-drawer
  5. title="人员编辑"
  6. :visible.sync="dialogTableVisible"
  7. size="80%"
  8. direction="rtl"
  9. append-to-body
  10. @close="onCancel"
  11. :show-close="false"
  12. >
  13. <div class="panel_Target">
  14. <el-row>
  15. <el-col :span="11">
  16. <div style="margin-top: 2%;margin-bottom: 2%">
  17. <el-input
  18. placeholder="请输入姓名"
  19. suffix-icon="el-icon-search"
  20. v-model="leftData.param.content.where.condition"
  21. @input="listDataLeft(leftData.param.content.pageNumber = 1)"
  22. @keyup.native.enter="listDataLeft(leftData.param.content.pageNumber = 1)"
  23. @clear="listDataLeft(leftData.param.content.pageNumber = 1)"
  24. style="width:60%"
  25. size="small"
  26. class="input-with-select inline-16" clearable>
  27. </el-input>
  28. </div>
  29. </el-col>
  30. <el-col :span="11" :offset="2">
  31. <div style="margin-top: 2%;margin-bottom: 2%">
  32. <el-input
  33. placeholder="请输入姓名"
  34. suffix-icon="el-icon-search"
  35. v-model="rightData.param.content.where.condition"
  36. @input="listDataRight(rightData.param.content.pageNumber = 1)"
  37. @keyup.native.enter="listDataRight(rightData.param.content.pageNumber = 1)"
  38. @clear="listDataRight(rightData.param.content.pageNumber = 1)"
  39. style="width:60%"
  40. size="small"
  41. class="input-with-select inline-16" clearable>
  42. </el-input>
  43. </div>
  44. </el-col>
  45. </el-row>
  46. <el-row>
  47. <el-col :span="11">
  48. <div>
  49. <tablelayout class="normal-margin inline" :layout="tablecols" :data="leftData.list" :custom="true" :checkbox="true" height="calc(100vh - 252px)" @checkboxCallBack="checkboxCallBackLeft">
  50. <template v-slot:customcol="scope">
  51. <p>{{scope.column.data[scope.column.columnname]}}</p>
  52. </template>
  53. </tablelayout>
  54. <div class="flex-align-center container normal-panel" style="float: left;">
  55. <p style="float: left">已选{{leftData.selection.length}}人</p>&nbsp;
  56. <p style="float: right">总共{{leftData.list.length}}人</p>
  57. </div>
  58. <!-- <div class="container normal-panel" style="float: right;">
  59. <el-pagination
  60. background
  61. small
  62. @size-change="handleSizeChangeLeft"
  63. @current-change="handleCurrentChangeLeft"
  64. :current-page="leftData.currentPage"
  65. :page-sizes="[20, 50, 100, 200]"
  66. layout="total,sizes, prev, pager, next, jumper"
  67. :total="leftData.total">
  68. </el-pagination>
  69. </div>-->
  70. </div>
  71. </el-col>
  72. <el-col :span="2">
  73. <div>
  74. <el-button type="primary" size="small" style="margin-left: 22%;margin-top: 70%" @click="addPersonal">添加<i class="el-icon-d-arrow-right"></i></el-button>
  75. <el-button icon="el-icon-d-arrow-left" type="primary" size="small" style="margin-left: 22%;margin-top: 30%" @click="delPersonal">移除</el-button>
  76. </div>
  77. </el-col>
  78. <el-col :span="11">
  79. <div>
  80. <tablelayout class="normal-margin inline" :layout="tablecols" :data="rightData.list" :custom="true" :checkbox="true" height="calc(100vh - 252px)" @checkboxCallBack="checkboxCallBackRight">
  81. <template v-slot:customcol="scope">
  82. <p>{{scope.column.data[scope.column.columnname]}}</p>
  83. </template>
  84. </tablelayout>
  85. <div class="flex-align-center container normal-panel" style="float: left;">
  86. <p style="float: left">已选{{rightData.selection.length}}人</p>&nbsp;
  87. <p style="float: right">总共{{rightData.list.length}}人</p>
  88. </div>
  89. <!-- <div class="container normal-panel" style="float: right;">
  90. <el-pagination
  91. background
  92. small
  93. @size-change="handleSizeChangeRight"
  94. @current-change="handleCurrentChangeRight"
  95. :current-page="rightData.currentPage"
  96. :page-sizes="[20, 50, 100, 200]"
  97. layout="total,sizes, prev, pager, next, jumper"
  98. :total="rightData.total">
  99. </el-pagination>
  100. </div>-->
  101. </div>
  102. </el-col>
  103. </el-row>
  104. </div>
  105. <!-- <div class="dialog-footer ">
  106. <el-button size="small" @click="onCancel" class="normal-btn-width">取 消</el-button>
  107. <el-button size="small" type="primary" @click="onSubmit" class="normal-btn-width">确 定</el-button>
  108. </div>-->
  109. <div class="fixed__btn__panel">
  110. <el-button size="small" @click="onCancel" class="normal-btn-width">取 消</el-button>
  111. <el-button size="small" type="primary" @click="onSubmit" class="normal-btn-width">确 定</el-button>
  112. </div>
  113. </el-drawer>
  114. </div>
  115. </template>
  116. <script>
  117. import tablelayout from '@/components/table/index.vue'
  118. export default {
  119. props:["data"],
  120. name: "addPersonal",
  121. components:{
  122. tablelayout
  123. },
  124. data(){
  125. return {
  126. dialogTableVisible:false,
  127. form:'',
  128. tablecols:[],
  129. list:[],
  130. selection:[],
  131. condition:'',
  132. leftData:{
  133. list:[],
  134. total:0,
  135. currentPage:0,
  136. condition:'',
  137. selection:[],
  138. param: {
  139. "id": 20220901091302,
  140. "content": {
  141. "pageNumber":1,
  142. "pageSize":20,
  143. "sa_salestargetbillid": 0,
  144. "type":'',
  145. "where": {
  146. "condition": ""
  147. }
  148. },
  149. },
  150. },
  151. rightData:{
  152. list:[],
  153. total:0,
  154. currentPage:0,
  155. condition:'',
  156. selection:[],
  157. hrid:[],
  158. param: {
  159. "id": 20220901091302,
  160. "content": {
  161. "pageNumber":1,
  162. "pageSize":20,
  163. "sa_salestargetbillid": 0,
  164. "type":1,
  165. "where": {
  166. "condition": ""
  167. }
  168. },
  169. },
  170. }
  171. }
  172. },
  173. methods:{
  174. onShow(){
  175. console.log(this.data)
  176. this.dialogTableVisible = true
  177. this.listDataLeft()
  178. this.listDataRight()
  179. },
  180. async listDataLeft(){
  181. /* this.leftData.param.content.where.condition = this.leftData.condition*/
  182. this.leftData.param.content.sa_salestargetbillid = this.data.sa_salestargetbillid
  183. const res = await this.$api.requested(this.leftData.param)
  184. /*res.data.forEach(e => {
  185. e.marea = e.area.map(m=>{
  186. return `${m.province}${m.city}${m.county}`
  187. })
  188. e.marea = e.marea.join(',')
  189. })*/
  190. this.leftData.list = res.data
  191. this.leftData.total = res.total
  192. this.leftData.currentPage = res.pageNumber
  193. },
  194. async listDataRight(){
  195. /* this.leftData.param.content.where.condition = this.leftData.condition*/
  196. this.rightData.param.content.sa_salestargetbillid = this.data.sa_salestargetbillid
  197. const res = await this.$api.requested(this.rightData.param)
  198. /*res.data.forEach(e => {
  199. e.marea = e.area.map(m=>{
  200. return `${m.province}${m.city}${m.county}`
  201. })
  202. e.marea = e.marea.join(',')
  203. })*/
  204. this.rightData.list = res.data
  205. this.rightData.total = res.total
  206. this.rightData.currentPage = res.pageNumber
  207. },
  208. onCancel(){
  209. this.dialogTableVisible = false
  210. this.leftData.param.condition = ''
  211. this.rightData.param.condition = ''
  212. this.listDataRight()
  213. this.listDataLeft()
  214. this.$emit("onSuccess")
  215. },
  216. async onSubmit(){
  217. this.dialogTableVisible = false
  218. this.$emit("onSuccess")
  219. /*console.log("执行")
  220. const res = await this.$api.requested({
  221. "id": 20220831165302,
  222. "content": {
  223. "year": this.data.year,
  224. "sa_salestargetbillid": this.data.sa_salestargetbillid,//新建年度是为0,添加人员时为具体的数据id
  225. "sales": this.selection
  226. },
  227. })
  228. this.tool.showMessage(res,()=>{
  229. this.dialogTableVisible = false
  230. this.$emit('onSuccess')
  231. })*/
  232. },
  233. async addPersonal(){
  234. console.log(this.leftData.selection)
  235. const res = await this.$api.requested({
  236. "id": 20220831165302,
  237. "content": {
  238. "year": this.data.year,
  239. "sa_salestargetbillid": this.data.sa_salestargetbillid,//新建年度是为0,添加人员时为具体的数据id
  240. "sales": this.leftData.selection
  241. },
  242. })
  243. this.tool.showMessage(res,()=>{
  244. this.listDataLeft()
  245. this.listDataRight()
  246. this.$emit("onSuccess")
  247. })
  248. },
  249. async delPersonal(){
  250. const res = await this.$api.requested({
  251. "id": 20220901111202,
  252. "content": {
  253. "sa_salestargetbillid": this.data.sa_salestargetbillid,
  254. "hrid": this.rightData.hrid
  255. },
  256. })
  257. this.tool.showMessage(res,()=>{
  258. this.listDataLeft()
  259. this.listDataRight()
  260. this.$emit("onSuccess")
  261. })
  262. },
  263. checkboxCallBackLeft (val) {
  264. this.leftData.selection = val
  265. console.log(this.leftData.selection)
  266. },
  267. checkboxCallBackRight (val) {
  268. this.rightData.selection = val
  269. console.log(this.rightData.selection)
  270. this.rightData.selection.forEach((item,index) => {
  271. this.rightData.hrid[index] = item.hrid
  272. console.log(this.rightData.hrid,'-----------------------------------')
  273. })
  274. },
  275. handleSizeChangeLeft(val){
  276. // console.log(`每页 ${val} 条`);
  277. this.leftData.param.content.pageSize = val
  278. this.listDataLeft()
  279. },
  280. handleCurrentChangeLeft(val){
  281. // console.log(`当前页: ${val}`);
  282. this.leftData.param.content.pageNumber = val
  283. this.listDataLeft()
  284. },
  285. handleSizeChangeRight(val){
  286. // console.log(`每页 ${val} 条`);
  287. this.rightData.param.content.pageSize = val
  288. this.listDataRight()
  289. },
  290. handleCurrentChangeRight(val){
  291. // console.log(`当前页: ${val}`);
  292. this.rightData.param.content.pageNumber = val
  293. this.listDataRight()
  294. }
  295. },
  296. mounted() {
  297. /*this.listDataLeft()
  298. this.listDataRight()*/
  299. },
  300. created () {
  301. this.tablecols = this.tool.tabelCol(this.$route.name)['personalTable'].tablecols
  302. }
  303. }
  304. </script>
  305. <style scoped>
  306. .panel_Target {
  307. border-top:1px solid #eeeeee;
  308. padding:5px 5px;
  309. margin-bottom:0px
  310. }
  311. >>> .el-dialog__body {
  312. padding: 0px 0px 10px;
  313. color: #606266;
  314. font-size: 14px;
  315. word-break: break-all;
  316. }
  317. >>> .el-dialog__header {
  318. padding: 10px 10px 10px ;
  319. }
  320. .dialog-footer{
  321. margin-top: 0px;
  322. margin-bottom: 10px;
  323. }
  324. >>> .el-dialog__title {
  325. line-height: 24px;
  326. font-size: 16px;
  327. color: #303133;
  328. }
  329. </style>