index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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 = that.tool.getStatusColor(that.mainData.status)
  131. return style
  132. }
  133. }
  134. ]
  135. },
  136. onSuccess () {
  137. this.queryMainData(this.$route.query.id)
  138. },
  139. async onImportSuccess (res) {
  140. let attachmentid = res.data.attachmentids[0]
  141. const res1 = await this.$api.requested({
  142. "id": 20220913092702,
  143. "content": {
  144. "attachmentid":attachmentid,
  145. "sa_salestargetbillid":this.$route.query.id,
  146. "year":this.mainData.year
  147. },
  148. })
  149. if (res1.msg !== '成功') {
  150. this.errorurl = res1.msg
  151. } else {
  152. this.errorurl = null
  153. }
  154. if (this.errorurl) {
  155. this.$message({
  156. message:this.$t('导入失败请查看错误文件'),
  157. type:'warning'
  158. })
  159. } else {
  160. this.tool.showMessage(res1,()=>{
  161. this.onSuccess()
  162. })
  163. }
  164. },
  165. delShow(data){
  166. this.$confirm(this.$t('此操作将删除该人员的人员目标, 是否继续?'), this.$t('提示'), {
  167. confirmButtonText: this.$t('确定'),
  168. cancelButtonText: this.$t('取消'),
  169. type: 'warning'
  170. }).then(() => {
  171. console.log('删除')
  172. console.log(data)
  173. this.onDel(data)
  174. }).catch(() => {
  175. this.$message({
  176. type: 'info',
  177. message: this.$t('已取消删除')
  178. });
  179. });
  180. },
  181. async onDel(data){
  182. const res = await this.$api.requested({
  183. "id": 20220901111202,
  184. "content": {
  185. "sa_salestargetbillid": this.$route.query.id,
  186. "hrid": [data]
  187. },
  188. })
  189. this.tool.showMessage(res,()=>{
  190. this.onSuccess()
  191. })
  192. }
  193. },
  194. mounted () {
  195. this.queryMainData(this.$route.query.id)
  196. console.log("人员目标id"+this.$route.query.id)
  197. },
  198. created () {
  199. /*this.onlyread = this.$route.query.type === 'onlyread'?true:false*/
  200. }
  201. }
  202. </script>
  203. <style>
  204. </style>