index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :data="dataList"
  5. ref="crud"
  6. v-model="form"
  7. :page.sync="page"
  8. :search.sync="search"
  9. :table-loading="loading"
  10. @search-change="searchChange"
  11. @search-reset="searchReset"
  12. @selection-change="selectionChange"
  13. @current-change="currentChange"
  14. @size-change="sizeChange"
  15. @refresh-change="refreshChange"
  16. @on-load="onLoad"
  17. @saveColumn="saveColumn"
  18. @resetColumn="resetColumn"
  19. >
  20. <template slot="menuLeft">
  21. <el-button
  22. icon="el-icon-printer"
  23. size="small"
  24. type="primary"
  25. :loading="exportLoading"
  26. @click.stop="downFile"
  27. >导 出
  28. </el-button>
  29. </template>
  30. <template slot="flagSearch">
  31. <el-select
  32. v-model="search.flag"
  33. placeholder=""
  34. @change="cut"
  35. >
  36. <el-option
  37. v-for="item in flagOptions"
  38. :key="item.value"
  39. :label="item.label"
  40. :value="item.value">
  41. </el-option>
  42. </el-select>
  43. </template>
  44. <template slot="userNameSearch">
  45. <el-select
  46. v-model="search.userName"
  47. remote
  48. filterable
  49. clearable
  50. :remote-method="userNameRemoteMethod"
  51. >
  52. <el-option
  53. v-for="item in userNameOptions"
  54. :key="item.value"
  55. :label="item.realName"
  56. :value="item.realName">
  57. </el-option>
  58. </el-select>
  59. </template>
  60. <template slot="corpNamesSearch">
  61. <crop-select
  62. v-model="search.corpNames"
  63. corpType="KH"
  64. style="width: 100%"
  65. ></crop-select>
  66. </template>
  67. </avue-crud>
  68. </basic-container>
  69. </template>
  70. <script>
  71. import option from "./config/mainList.json";
  72. import clientOption from "./config/clientList.json";
  73. import { performanceAnalysis ,importAnalysis} from "@/api/workManagement/mainProject";
  74. import { getUserList } from "@/api/workManagement/mainProject";
  75. export default {
  76. data() {
  77. return {
  78. form: {},
  79. search:{},
  80. option: {},
  81. exportLoading:false,
  82. loading:false,
  83. dataList: [],
  84. userNameOptions:[],
  85. flagOptions:[{
  86. value: '1',
  87. label: '承做人'
  88. }, {
  89. value: '2',
  90. label: '客户'
  91. }],
  92. page: {
  93. currentPage: 1,
  94. total: 0,
  95. pageSize: 10,
  96. pageSizes: [10, 50, 100, 200, 300, 400, 500,1000]
  97. },
  98. }
  99. },
  100. async created() {
  101. this.option = await this.getColumnData(this.getColumnName(58), option);
  102. getUserList().then(res=>{
  103. res.data.data.map((item,index)=>{
  104. if(index <= 20){
  105. this.userNameOptions.push(item)
  106. }
  107. })
  108. })
  109. },
  110. mounted() {
  111. },
  112. methods: {
  113. downFile(){
  114. this.exportLoading = true
  115. let searchParams = Object.assign({},this.search);
  116. let param = this.paramsAdjustment(searchParams)
  117. let option = this.deepClone(this.option.column)
  118. importAnalysis(param).then(res=>{
  119. option.shift();
  120. option.shift();
  121. this.$Export.excel({
  122. title: "业绩分析",
  123. columns: option,
  124. data: res.data.data,
  125. });
  126. }).finally(()=>{
  127. this.exportLoading = false
  128. })
  129. },
  130. cut(val){
  131. if(val == 1){
  132. this.option = option
  133. this.onLoad(this.page,this.search)
  134. }else{
  135. this.option = clientOption
  136. this.onLoad(this.page,this.search)
  137. }
  138. },
  139. userNameRemoteMethod(val){
  140. getUserList({realName : val}).then(res=>{
  141. this.userNameOptions = res.data.data
  142. })
  143. },
  144. //新单打开
  145. addReceipt(row){
  146. console.log(1)
  147. },
  148. //编辑打开
  149. editOpen(row){
  150. console.log(1)
  151. },
  152. searchReset() {
  153. console.log('1')
  154. },
  155. selectionChange() {
  156. console.log('1')
  157. },
  158. sizeChange(val) {
  159. this.page.currentPage = 1;
  160. this.page.pageSize = val;
  161. },
  162. currentChange(val) {
  163. this.page.currentPage = val
  164. },
  165. refreshChange(params) {
  166. this.onLoad(this.page,params);
  167. },
  168. //点击搜索按钮触发
  169. searchChange(params,done) {
  170. this.onLoad(this.page, params);
  171. done()
  172. },
  173. paramsAdjustment(params) {
  174. params = Object.assign({}, this.search);
  175. if(!params.flag){
  176. params.flag = "1"
  177. }
  178. if(!params.year){
  179. params.year = "2021"
  180. }
  181. return params
  182. },
  183. onLoad(page, params) {
  184. this.loading = true;
  185. params = this.paramsAdjustment(params)
  186. performanceAnalysis(page.currentPage, page.pageSize,params).then(res=>{
  187. this.dataList = res.data.data.records
  188. this.page.total = res.data.data.total
  189. }).finally(()=>{
  190. this.loading = false;
  191. })
  192. },
  193. //列保存触发
  194. async saveColumn() {
  195. const inSave = await this.saveColumnData(
  196. this.getColumnName(58),
  197. this.option
  198. );
  199. if (inSave) {
  200. this.$message.success("保存成功");
  201. //关闭窗口
  202. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  203. }
  204. },
  205. async resetColumn() {
  206. const inSave = await this.delColumnData(
  207. this.getColumnName(58),
  208. option
  209. );
  210. if (inSave) {
  211. this.$message.success("重置成功");
  212. this.option = option;
  213. //关闭窗口
  214. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  215. }
  216. },
  217. },
  218. }
  219. </script>
  220. <style scoped>
  221. </style>