index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <div>
  3. <basicDetails
  4. ref="details"
  5. :titleText="$t('年度目标') + mainData.year + '年'"
  6. :editData="mainData"
  7. :mainAreaData="mainAreaData"
  8. :turnPageId="20220901132502"
  9. idname="sa_salestargetbillid"
  10. ownertable="sa_salestargetbill"
  11. delApiId="20221118103402"
  12. tags=""
  13. :tabs="[$t('人员目标详情'),$t('详细信息')]"
  14. :statusCheck="[{key:'status',value:'已下达'},{key:'status',value:'关闭'}]"
  15. @pageChange="pageChange"
  16. @onEditSuccess="queryMainData($route.query.id)"
  17. @onTabClick="onTabClick">
  18. <div slot="customOperation">
  19. <!-- 此区域提供了自定义操作按钮 -->
  20. <issue :data="mainData" @onSuccess="onSuccess"></issue>
  21. <adjustment :data="mainData" @onSuccess="onSuccess" ></adjustment>
  22. <close v-if="mainData.status === '已下达'" :data="mainData" @onClose="onSuccess"></close>
  23. <restore v-if="tool.checkAuth($route.name,'restore')" :data="mainData" class="inline-16" @restSuccess="onSuccess"></restore>
  24. <importFile v-if="mainData.status === '新建'" class="inline-16" accept=".xlsx" :folderid="folderid" :bindData="{ownertable:'sa_salestargetbill',ownerid:'',usetype:'default'}" @onImportSuccess="onImportSuccess">
  25. <a class="error-link" v-if="errorurl" :href="errorurl" slot="errorFile">{{ $t('下载错误数据') }}</a>
  26. </importFile>
  27. </div>
  28. <div slot="slot0">
  29. <addPerson v-if="tool.checkAuth($route.name,'personalTargetManage')" style="margin-bottom: 10px" :data="mainData" @addSuccess="onSuccess"></addPerson>
  30. <targetTable ref="list" >
  31. <template v-slot:editTarget="scope">
  32. <editTarget class="inline-16" v-if="tool.checkAuth($route.name,'personalTargetManage')" :disabled="mainData.status != '新建'" style="display:inline" :year="mainData.year" :data="scope.data" @onSuccess="onSuccess"></editTarget>
  33. <el-button type="text" v-if="tool.checkAuth($route.name,'personalTargetManage')" :disabled="mainData.status != '新建' " size="small" @click="delShow(scope.data.hrid)">{{$t('删 除')}}</el-button>
  34. </template>
  35. <!-- <template v-slot:del="scope">
  36. <ondel v-if="tool.checkAuth($route.name,'delete')" :data="scope.data" @onSuccess="onSuccess"></ondel>
  37. </template>-->
  38. </targetTable>
  39. </div>
  40. <div slot="slot1">
  41. <detail_information ref="detailed"></detail_information>
  42. </div>
  43. </basicDetails>
  44. </div>
  45. </template>
  46. <script>
  47. import add from './components/add.vue'
  48. import ondel from './components/del.vue'
  49. import editTarget from './components/editTarget.vue'
  50. import importFile from './components/importFile.vue'
  51. import restore from './components/restore.vue'
  52. import targetTable from './components/table.vue'
  53. import detail_information from './modules/detailedInformation/index'
  54. import issue from '../issue'
  55. import adjustment from '../adjustment'
  56. import close from '../close'
  57. import addPerson from './components/addPerson'
  58. export default {
  59. components:{
  60. targetTable,
  61. add,
  62. ondel,
  63. editTarget,
  64. importFile,
  65. detail_information,
  66. issue,
  67. adjustment,
  68. close,
  69. addPerson,
  70. restore
  71. },
  72. data () {
  73. return {
  74. mainData:{},
  75. mainAreaData:[],
  76. mainInfo:{},
  77. folderid:JSON.parse(sessionStorage.getItem('folderid')).appfolderid,
  78. errorurl:null
  79. }
  80. },
  81. methods:{
  82. onTabClick () {
  83. // setTimeout(e=>{
  84. // this.$refs.list.queryData(this.mainData.year)
  85. // },2000)
  86. // console.log(this.$refs.list)
  87. this.$nextTick(e=>{
  88. this.$refs.list? this.$refs.list.queryData(this.mainData.year):''
  89. this.$refs.detailed? this.$refs.detailed.detailedList(this.mainData):''
  90. })
  91. },
  92. async queryMainData(id) {
  93. const res = await this.$api.requested({
  94. "id": 20220901140402,
  95. "content": {
  96. "sa_salestargetbillid": id
  97. }
  98. })
  99. this.mainData = res.data
  100. console.log(this.mainData)
  101. this.$refs.list.queryData(this.mainData.year)
  102. /*this.$refs.detailed.detailedList(this.mainData)*/
  103. this.changeDataStructure()
  104. },
  105. // 监听切换数据,上一页,下一页
  106. pageChange (id,rowindex) {
  107. this.flag = false
  108. this.$router.replace({path:'/personalTarget_edit',query:{id:id,rowindex:rowindex}})
  109. this.queryMainData(id)
  110. },
  111. changeDataStructure(){
  112. let that = this
  113. this.mainAreaData = [
  114. {
  115. label:this.$t('年度'),
  116. value:this.mainData.year
  117. },
  118. {
  119. label:this.$t('编制方式'),
  120. value:this.mainData.targettype
  121. },
  122. {
  123. label:this.$t('人员数'),
  124. value:this.mainData.peoplecount
  125. },
  126. {
  127. label:this.$t('状态'),
  128. value:this.$t(this.mainData.status),
  129. style:function () {
  130. let style = {}
  131. switch (that.mainData.status) {
  132. case '新建':
  133. style = {color:'#3874f6'}
  134. break;
  135. case '已下达':
  136. style = {color:'#67C23A'}
  137. break;
  138. case '关闭':
  139. style = {color:'#cccccc'}
  140. break;
  141. default:
  142. break;
  143. }
  144. return style
  145. }
  146. }
  147. ]
  148. },
  149. onSuccess () {
  150. console.log("执行")
  151. this.queryMainData(this.$route.query.id)
  152. },
  153. async onImportSuccess (res) {
  154. let attachmentid = res.data.attachmentids[0]
  155. const res1 = await this.$api.requested({
  156. "id": 20220913092702,
  157. "content": {
  158. "attachmentid":attachmentid,
  159. "sa_salestargetbillid":this.$route.query.id,
  160. "year":this.mainData.year
  161. },
  162. })
  163. if (res1.msg !== '成功') {
  164. this.errorurl = res1.msg
  165. } else {
  166. this.errorurl = null
  167. }
  168. if (this.errorurl) {
  169. this.$message({
  170. message:this.$t('导入失败请查看错误文件'),
  171. type:'warning'
  172. })
  173. } else {
  174. this.tool.showMessage(res1,()=>{
  175. this.onSuccess()
  176. })
  177. }
  178. },
  179. delShow(data){
  180. this.$confirm(this.$t('此操作将删除该人员的人员目标, 是否继续?'), this.$t('提示'), {
  181. confirmButtonText: this.$t('确定'),
  182. cancelButtonText: this.$t('取消'),
  183. type: 'warning'
  184. }).then(() => {
  185. console.log('删除')
  186. console.log(data)
  187. this.onDel(data)
  188. }).catch(() => {
  189. this.$message({
  190. type: 'info',
  191. message: this.$t('已取消删除')
  192. });
  193. });
  194. },
  195. async onDel(data){
  196. const res = await this.$api.requested({
  197. "id": 20220901111202,
  198. "content": {
  199. "sa_salestargetbillid": this.$route.query.id,
  200. "hrid": [data]
  201. },
  202. })
  203. this.tool.showMessage(res,()=>{
  204. this.onSuccess()
  205. })
  206. }
  207. },
  208. mounted () {
  209. this.queryMainData(this.$route.query.id)
  210. console.log("人员目标id"+this.$route.query.id)
  211. },
  212. created () {
  213. /*this.onlyread = this.$route.query.type === 'onlyread'?true:false*/
  214. }
  215. }
  216. </script>
  217. <style>
  218. </style>