finance.vue 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359
  1. <template>
  2. <section>
  3. <!--工具条-->
  4. <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  5. <el-form :inline="true">
  6. <!-- <el-form-item label="财务核算成本 | 月份选择" style="margin-top:5px;"> -->
  7. <el-form-item label="月份选择" >
  8. <el-date-picker size="small" v-model="date" :editable="false" format="yyyy-MM" value-format="yyyy-MM" @change="changeMonth" :clearable="false" type="month" placeholder="选择月份" style="margin-right: 20px"></el-date-picker>
  9. <el-link type="primary" :underline="false" @click="audits()" v-if="user.timeType.financeAudit == '1'">{{revaelse}}</el-link>
  10. </el-form-item>
  11. <!-- <el-radio-group v-model="radio" @change="switchList" style="margin-left:160px;margin-top:5px;"> -->
  12. <el-radio-group size="small" v-model="radio" @change="switchList" style="margin-left:150px;margin-top:5px;">
  13. <el-radio-button label="全部人员" >全部人员({{allFinanceList.length}})</el-radio-button>
  14. <el-radio-button label="无项目工时人员">无项目工时人员({{noReportUserList.length}})</el-radio-button>
  15. </el-radio-group>
  16. <el-form-item v-if="user.role == 1 || user.role == 2 || user.role == 4" style="margin-left:5px;">
  17. <el-link type="primary" :underline="false" @click="showSettingDialog()" >分摊比例设置</el-link>
  18. </el-form-item>
  19. <el-form-item style="float:right;" v-if="user.role == 1 || user.role == 2 || user.role == 4">
  20. <el-link type="primary" :underline="false" @click="getTemplate()" >模板下载</el-link>
  21. </el-form-item>
  22. <!-- <el-form-item style="float:right;">
  23. <el-upload ref="upload" action="#" :limit="1" :http-request="importFinance" :show-file-list="false">
  24. <el-link type="primary" :underline="false" >财务数据上传</el-link>
  25. </el-upload>
  26. </el-form-item> -->
  27. <el-form-item style="float:right;" v-if="user.role == 1 || user.role == 2 || user.role == 4">
  28. <el-link type="primary" :underline="false" @click="importDialog = true;isUploading=false;">数据上传</el-link>
  29. </el-form-item>
  30. <el-form-item style="float:right;" v-if="(user.role == 1 || user.role == 2 || user.role == 4)">
  31. <el-link type="primary" :underline="false" @click="exportDialog = true;exportMonth = date;">数据导出</el-link>
  32. </el-form-item>
  33. <el-form-item style="float:right;" v-if="user.role == 1 || user.role == 2 || user.role == 4">
  34. <el-link type="primary" :underline="false" @click="showItemDialog">自定义薪资项</el-link>
  35. </el-form-item>
  36. <el-form-item style="float:right;" v-if="(user.role == 1 || user.role == 2 || user.role == 4) && user.timeType.financeAudit == '1'">
  37. <el-link type="primary" :underline="false" @click="reviewerVisible = true">设置审核人</el-link>
  38. </el-form-item>
  39. </el-form>
  40. </el-col>
  41. <!-- 上传记录 -->
  42. <el-dialog title="薪资上传记录" :visible.sync="xzImportVisible" width="1100px" :before-close="handleClose">
  43. <div>
  44. <el-table :data="xzList" style="width: 100%" :height="400">
  45. <el-table-column prop="userName" label="操作人"></el-table-column>
  46. <el-table-column prop="ymonth" label="所属月份"></el-table-column>
  47. <el-table-column prop="fileName" label="文件名">
  48. <template slot-scope="scope">
  49. <div>
  50. <el-link type="primary" @click="downloadByA({name:scope.row.fileName,url:scope.row.serverName})"> {{scope.row.fileName}}</el-link>
  51. </div>
  52. </template>
  53. </el-table-column>
  54. <el-table-column prop="recoverReport" label="是否覆盖日报成本" width="150">
  55. <template slot-scope="scope">
  56. <div>
  57. {{scope.row.recoverReport == 1? '是' : '否'}}
  58. </div>
  59. </template>
  60. </el-table-column>
  61. <el-table-column prop="recoverMonthcost" label="是否覆盖人员月成本" width="150">
  62. <template slot-scope="scope">
  63. <div>
  64. {{scope.row.recoverMonthcost == 1? '是' : '否'}}
  65. </div>
  66. </template>
  67. </el-table-column>
  68. <el-table-column prop="indate" label="上传时间"></el-table-column>
  69. <!-- <el-table-column prop="date" label="操作" v-if="(tabPosition == 1 || tabPosition == 0) && (reviewerRuleForm.auditorId == user.id || user.role == 1 || user.role == 2)">
  70. <template slot-scope="scope">
  71. <div>
  72. <el-button type="primary" size="small" v-if="tabPosition == 0" @click="operationList(0, scope.row.id)">通过</el-button>
  73. <el-button type="warning" size="small" v-if="tabPosition == 0" @click="operationList(1, scope.row.id)">驳回</el-button>
  74. <el-button type="warning" size="small" v-if="tabPosition == 1" @click="operationList(2, scope.row.id)">撤销</el-button>
  75. </div>
  76. </template>
  77. </el-table-column> -->
  78. </el-table>
  79. </div>
  80. </el-dialog>
  81. <!-- 财务报表审核 -->
  82. <el-dialog :title="shenhe" :visible.sync="importVisible" width="1100px" :before-close="handleClose">
  83. <div>
  84. <el-radio-group v-model="tabPosition" style="margin-bottom: 20px;" @change="operationalData()">
  85. <el-radio-button label="1">已通过</el-radio-button>
  86. <el-radio-button label="0">待审核</el-radio-button>
  87. <el-radio-button label="2">已驳回</el-radio-button>
  88. <el-radio-button label="-1">已撤销</el-radio-button>
  89. </el-radio-group>
  90. <el-table :data="reviewLis" style="width: 100%" :height="400">
  91. <el-table-column prop="userName" label="操作人"></el-table-column>
  92. <el-table-column prop="ymonth" label="所属月份"></el-table-column>
  93. <el-table-column prop="fileName" label="文件名">
  94. <template slot-scope="scope">
  95. <div>
  96. <el-link type="primary" @click="downloadByA({name:scope.row.fileName,url:scope.row.serverName})"> {{scope.row.fileName}}</el-link>
  97. </div>
  98. </template>
  99. </el-table-column>
  100. <el-table-column prop="recoverReport" label="是否覆盖日报成本" width="150">
  101. <template slot-scope="scope">
  102. <div>
  103. {{scope.row.recoverReport == 1? '是' : '否'}}
  104. </div>
  105. </template>
  106. </el-table-column>
  107. <el-table-column prop="recoverMonthcost" label="是否覆盖人员月成本" width="150">
  108. <template slot-scope="scope">
  109. <div>
  110. {{scope.row.recoverMonthcost == 1? '是' : '否'}}
  111. </div>
  112. </template>
  113. </el-table-column>
  114. <el-table-column prop="indate" label="上传时间"></el-table-column>
  115. <el-table-column prop="date" label="操作" v-if="(tabPosition == 1 || tabPosition == 0) && (reviewerRuleForm.auditorId == user.id || user.role == 1 || user.role == 2)">
  116. <template slot-scope="scope">
  117. <div>
  118. <el-button type="primary" size="small" v-if="tabPosition == 0" @click="operationList(0, scope.row.id)">通过</el-button>
  119. <el-button type="warning" size="small" v-if="tabPosition == 0" @click="operationList(1, scope.row.id)">驳回</el-button>
  120. <el-button type="warning" size="small" v-if="tabPosition == 1" @click="operationList(2, scope.row.id)">撤销</el-button>
  121. </div>
  122. </template>
  123. </el-table-column>
  124. </el-table>
  125. </div>
  126. </el-dialog>
  127. <!-- 设置审核人弹窗 -->
  128. <el-dialog title="设置审核人" :visible.sync="reviewerVisible" width="350px" :before-close="handleCloses">
  129. <el-form :model="reviewerRuleForm" ref="reviewerRuleForm" label-width="100px" class="demo-ruleForm">
  130. <el-form-item label="选择审核人" prop="auditorId" :rules="{required: true, message: '审核人不能为空', trigger: 'blur'}">
  131. <el-select v-model="reviewerRuleForm.auditorId" clearable placeholder="请选择审核人" >
  132. <el-option v-for="(item, index) in people" :key="index" :label="item.name" :value="item.id"></el-option>
  133. </el-select>
  134. </el-form-item>
  135. <el-form-item>
  136. <el-button type="primary" @click="submitreviewerRuleForm('reviewerRuleForm')">提交</el-button>
  137. </el-form-item>
  138. </el-form>
  139. </el-dialog>
  140. <el-dialog title="财务数据导出" v-if="exportDialog" :visible.sync="exportDialog" :close-on-click-modal="false" customClass="customWidth" width="400px">
  141. <el-form ref="form3" >
  142. <el-form-item label="导出月份" >
  143. <!-- <div style="color:orange;">{{date}}</div> -->
  144. <el-date-picker v-model="exportMonth" type="month" placeholder="选择月份" format="yyyy-MM" value-format="yyyy-MM" style="width:280px;"></el-date-picker>
  145. </el-form-item>
  146. </el-form>
  147. <div slot="footer" class="dialog-footer">
  148. <el-button type="primary" style="width:100%;" :loading="isUploading" @click="exportFinance">导出</el-button>
  149. </div>
  150. </el-dialog>
  151. <!--列表-->
  152. <!-- 222 -->
  153. <el-table :data="list" highlight-current-row v-loading="listLoading"
  154. show-summary=true
  155. ref="table"
  156. :height="300" style="width: 100%;">
  157. <el-table-column prop="name" label="姓名" sortable width="150"></el-table-column>
  158. <el-table-column :prop="headerCols[index]" :label="item" sortable show-overflow-tooltip v-for="(item, index) in tblCols"
  159. :key="index">
  160. </el-table-column>
  161. <!-- <el-table-column prop="monthCost" label="customCols.monthCost" width="150"></el-table-column>
  162. <el-table-column prop="bonus" :label="customCols.bonus" ></el-table-column>
  163. <el-table-column prop="allowance" :label="customCols.allowance" ></el-table-column>
  164. <el-table-column prop="insuranceOld" :label="customCols.insuranceOld" ></el-table-column>
  165. <el-table-column prop="insuranceMedical" :label="customCols.insuranceMedical" ></el-table-column>
  166. <el-table-column prop="insuranceLosejob" :label="customCols.insuranceLosejob" ></el-table-column>
  167. <el-table-column prop="insuranceInjury" :label="customCols.insuranceInjury" ></el-table-column>
  168. <el-table-column prop="houseFund" :label="customCols.houseFund" ></el-table-column> -->
  169. <!-- <el-table-column prop="field1" :label="customCols.field1" ></el-table-column>
  170. <el-table-column prop="field2" :label="customCols.field2" ></el-table-column>
  171. <el-table-column prop="field3" :label="customCols.field3" ></el-table-column> -->
  172. <!-- <el-table-column prop="monthCost" :label="customCols.monthCost" width="150"></el-table-column>
  173. <el-table-column prop="bonus" :label="customCols.bonus" ></el-table-column>
  174. <el-table-column prop="allowance" :label="customCols.allowance" ></el-table-column>
  175. <el-table-column prop="insuranceOld" :label="customCols.insuranceOld" ></el-table-column>
  176. <el-table-column prop="insuranceMedical" :label="customCols.insuranceMedical" ></el-table-column>
  177. <el-table-column prop="insuranceLosejob" :label="customCols.insuranceLosejob" ></el-table-column>
  178. <el-table-column prop="insuranceInjury" :label="customCols.insuranceInjury" ></el-table-column>
  179. <el-table-column prop="houseFund" :label="customCols.houseFund" ></el-table-column>
  180. <el-table-column prop="field1" :label="customCols.field1" ></el-table-column>
  181. <el-table-column prop="field2" :label="customCols.field2" ></el-table-column>
  182. <el-table-column prop="field3" :label="customCols.field3" ></el-table-column> -->
  183. <!-- <el-table-column prop="others" label="其他" ></el-table-column> -->
  184. <!-- <el-table-column :label="item.fieldName" v-for="(item, index) in customCols" :key="item.id" :prop="index==0?'customField1':(index==1?'customField2':(index==2?'customField3':''))">
  185. <template slot-scope="scope">
  186. {{index==0?scope.row.customField1:(index==1?scope.row.customField2:(index==2?scope.row.customField3:''))}}
  187. </template>
  188. </el-table-column> -->
  189. <el-table-column prop="totalCost" label="总成本" ></el-table-column>
  190. </el-table>
  191. <el-form :inline="true" >
  192. <el-form-item >
  193. <!-- <el-checkbox style="margin-left:10px;" v-model="assignNoProUser" @click="assignToProject">均摊无项目人员成本</el-checkbox> -->
  194. <!-- <el-button type="primary" :underline="false" size="small" @click="assignNoProUser=false;assignToProject();" style="margin-left:10px;">分摊已填工时人员成本</el-button>
  195. <el-button type="primary" :underline="false" size="small" @click="assignNoProUser=true;assignToProject();" style="margin-left:10px;">分摊全部人员成本</el-button> -->
  196. <el-radio-group v-model="costListRadio" @change="switchCostList" style="margin-left:5px;margin-top:5px;">
  197. <el-radio-button label="1" >分摊已填工时人员成本</el-radio-button>
  198. <el-radio-button label="2">分摊全部人员成本</el-radio-button>
  199. </el-radio-group>
  200. </el-form-item>
  201. <el-form-item style="float:right;margin-right:20px;">
  202. <el-link type="primary" :underline="false" @click="exportData">导出分摊数据</el-link>
  203. </el-form-item>
  204. <!-- <el-form-item style="float:right;margin-right:30px;" v-if="hasNoProjectUsers">
  205. <el-link type="primary" :underline="false" @click="showNoProjectUsers">查看无项目数据</el-link>
  206. </el-form-item> -->
  207. </el-form>
  208. <div id="container" style="height:300px"></div>
  209. <!--新增界面-->
  210. <el-dialog :title="title" v-if="addFormVisible" :visible.sync="addFormVisible" :close-on-click-modal="false" customClass="customWidth" width="600px">
  211. <el-form ref="form1" :model="addForm" :rules="rules" label-width="100px">
  212. <el-form-item label="项目编号" >
  213. <el-input v-model="addForm.code" placeholder="请输入项目编号" clearable></el-input>
  214. </el-form-item>
  215. <el-form-item label="项目名称" prop="name">
  216. <el-input v-model="addForm.name" placeholder="请输入项目名称" clearable></el-input>
  217. </el-form-item>
  218. <el-form-item label="全部参与者">
  219. <el-select v-model="addForm.userId" multiple filterable placeholder="请选择参与者" style="width:100%;" @change="changeParticipator">
  220. <el-option v-for="item in users" :key="item.id" :label="item.name" :value="item.id"></el-option>
  221. </el-select>
  222. </el-form-item>
  223. <el-form-item label="主要负责人" >
  224. <el-select v-model="addForm.inchargerId" :disabled="addForm.userId.length==0" filterable placeholder="请选择负责人" style="width:100%;" @change="changeIncharger">
  225. <el-option v-for="item in participator" :key="item.id" :label="item.name" :value="item.id"></el-option>
  226. </el-select>
  227. </el-form-item>
  228. </el-form>
  229. <div slot="footer" class="dialog-footer">
  230. <el-button @click.native="addFormVisible = false">取消</el-button>
  231. <el-button type="primary" @click="submitInsert" :loading="addLoading">提交</el-button>
  232. </div>
  233. </el-dialog>
  234. <!--用户详细信息弹出框-->
  235. <el-dialog title="查看详情" v-if="userDetailVisible" :visible.sync="userDetailVisible" :close-on-click-modal="false" customClass="customWidth" width="400px">
  236. <div class="line"><span>姓名</span><span>{{userDetail.name}}</span></div>
  237. <div class="line"><span>手机号码</span><span>{{userDetail.phone}}</span></div>
  238. <div class="line"><span>部门</span><span>{{userDetail.departmentName}}</span></div>
  239. <div class="line"><span>成本</span><span>{{userDetail.cost}}元/小时</span></div>
  240. <div slot="footer" class="dialog-footer">
  241. <el-button type="primary" @click="userDetailVisible = false" >确定</el-button>
  242. </div>
  243. </el-dialog>
  244. <!--导入时的设置界面 -->
  245. <el-dialog title="财务数据导入" v-if="importDialog" :visible.sync="importDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
  246. <el-form ref="form3" :model="importParam" >
  247. <el-form-item label="导入月份" >
  248. <!-- <div style="color:orange;">{{date}}</div> -->
  249. <el-date-picker v-model="date" type="month" placeholder="选择月份" format="yyyy-MM" value-format="yyyy-MM"></el-date-picker>
  250. </el-form-item>
  251. <el-form-item prop="syncHistoryReport" >
  252. <el-checkbox label="重新计算该月已填日报成本" v-model="importParam.syncHistoryReport"></el-checkbox>
  253. </el-form-item>
  254. <el-form-item prop="syncUserCost" >
  255. <el-checkbox label="同步到组织架构中员工月薪成本" v-model="importParam.syncUserCost" ></el-checkbox>
  256. </el-form-item>
  257. </el-form>
  258. <div slot="footer" class="dialog-footer">
  259. <el-link v-if="(user.role == 1 || user.role == 2 || user.role == 4) && user.timeType.financeAudit == '0'"
  260. style="float:left;"
  261. type="primary" :underline="false" @click="xzjl(),xzImportVisible = true">查看导入历史记录</el-link>
  262. <el-upload ref="upload" action="#" :limit="1" :http-request="importFinance" :show-file-list="false" >
  263. <el-button type="primary" style="width:100%;" :loading="isUploading" >选择文件并开始导入</el-button>
  264. </el-upload>
  265. </div>
  266. </el-dialog>
  267. <!--无项目人员列表-->
  268. <!-- <el-dialog title="无项目人员列表" v-if="showNPDialog" :visible.sync="showNPDialog" :close-on-click-modal="false" customClass="customWidth" width="1200px">
  269. <el-table :data="npUserList" highlight-current-row v-loading="listLoading"
  270. show-summary=true
  271. ref="table"
  272. :height="400" style="width: 100%;">
  273. <el-table-column prop="name" label="姓名" sortable width="150"></el-table-column>
  274. <el-table-column prop="monthCost" label="工资" width="150"></el-table-column>
  275. <el-table-column prop="bonus" label="奖金" ></el-table-column>
  276. <el-table-column prop="allowance" label="津贴" ></el-table-column>
  277. <el-table-column prop="insuranceOld" label="养老保险" ></el-table-column>
  278. <el-table-column prop="insuranceMedical" label="医疗保险" ></el-table-column>
  279. <el-table-column prop="insuranceLosejob" label="失业保险" ></el-table-column>
  280. <el-table-column prop="insuranceInjury" label="工伤保险" ></el-table-column>
  281. <el-table-column prop="houseFund" label="住房公积金" ></el-table-column>
  282. <el-table-column prop="others" label="其他" ></el-table-column>
  283. <el-table-column :label="item.fieldName" v-for="(item, index) in customCols" :key="item.id" :prop="index==0?'customField1':(index==1?'customField2':(index==2?'customField3':''))">
  284. <template slot-scope="scope">
  285. {{index==0?scope.row.customField1:(index==1?scope.row.customField2:(index==2?scope.row.customField3:''))}}
  286. </template>
  287. </el-table-column>
  288. <el-table-column prop="totalCost" label="总成本" ></el-table-column>
  289. </el-table>
  290. <div slot="footer" class="dialog-footer">
  291. <div style="float:left;color:#ff9900;">*以上人员当月尚无投入的项目,请提醒他们填写日报。</div>
  292. <el-button type="primary" @click="showNPDialog = false" >关闭</el-button>
  293. </div>
  294. </el-dialog> -->
  295. <el-dialog title="自定义薪资项" show-header="false" v-if="itemDialog" :visible.sync="itemDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
  296. <div style="margin-left:30px;">
  297. <!-- 111 -->
  298. <span style="color:#999;">薪资表包含以下数据</span>
  299. <p><el-input v-model="customCols.monthCost" placeholder="请输入自定义薪资项名称" style="width:200px;" maxlength="8"></el-input></p>
  300. <p><el-input v-model="customCols.bonus" placeholder="请输入自定义薪资项名称" style="width:200px;" maxlength="8"></el-input></p>
  301. <p><el-input v-model="customCols.allowance" placeholder="请输入自定义薪资项名称" style="width:200px;" maxlength="8"></el-input></p>
  302. <p><el-input v-model="customCols.insuranceOld" placeholder="请输入自定义薪资项名称" style="width:200px;" maxlength="8"></el-input></p>
  303. <p><el-input v-model="customCols.insuranceMedical" placeholder="请输入自定义薪资项名称" style="width:200px;" maxlength="8"></el-input></p>
  304. <p><el-input v-model="customCols.insuranceLosejob" placeholder="请输入自定义薪资项名称" style="width:200px;" maxlength="8"></el-input></p>
  305. <p><el-input v-model="customCols.insuranceInjury" placeholder="请输入自定义薪资项名称" style="width:200px;" maxlength="8"></el-input></p>
  306. <p><el-input v-model="customCols.houseFund" placeholder="请输入自定义薪资项名称" style="width:200px;" maxlength="8"></el-input></p>
  307. <p><el-input v-model="customCols.field1" placeholder="请输入自定义薪资项1名称" style="width:200px;" maxlength="8"></el-input></p>
  308. <p><el-input v-model="customCols.field2" placeholder="请输入自定义薪资项2名称" style="width:200px;" maxlength="8"></el-input></p>
  309. <p><el-input v-model="customCols.field3" placeholder="请输入自定义薪资项3名称" style="width:200px;" maxlength="8"></el-input></p>
  310. </div>
  311. <div slot="footer" class="dialog-footer">
  312. <el-button type="primary" @click="itemDialog = false" >关闭</el-button>
  313. <el-button type="primary" @click="saveItems()" >保存</el-button>
  314. </div>
  315. </el-dialog>
  316. <el-dialog :title="date+'月 无项目工时人员分摊比例设置'" show-header="false" v-if="settingDialog" :visible.sync="settingDialog"
  317. :close-on-click-modal="false" customClass="customWidth" width="1200px">
  318. <div>
  319. <div>
  320. <el-button :disabled="multipleSelection.length==0" @click="setPercent(true, null)">批量设置比例</el-button>
  321. <el-button :disabled="projectCols.length==0 || userCostSettingList.length == 0" @click="getLastMonthSetting">使用上月比例设置</el-button>
  322. <el-button @click="showSelectProjectDialog">管理待分摊项目</el-button>
  323. </div>
  324. <el-table :data="userCostSettingList" highlight-current-row v-loading="costSettingLoading"
  325. ref="settingTable" @selection-change="handleSelectionChange"
  326. :height="400" style="width: 100%;">
  327. <el-table-column type="selection" width="55"></el-table-column>
  328. <el-table-column prop="name" label="姓名" sortable width="90" fixed="left"></el-table-column>
  329. <el-table-column :label="item.projectName" v-for="(item) in projectCols" width="180" size="small"
  330. :key="item.id" align="center">
  331. <template slot-scope="scope">
  332. <span>{{scope.row[item.projectId]}}</span>%
  333. </template>
  334. </el-table-column>
  335. <el-table-column label="设置比例" width="80" fixed="right">
  336. <template slot-scope="scope">
  337. <el-button size="small" @click="setPercent(false,scope.row)">设置</el-button>
  338. </template>
  339. </el-table-column>
  340. </el-table>
  341. </div>
  342. <div slot="footer" class="dialog-footer">
  343. <el-button type="primary" @click="settingDialog = false" >关闭</el-button>
  344. <el-button type="primary" @click="saveMonthSetting()" >保存</el-button>
  345. </div>
  346. </el-dialog>
  347. <el-dialog title="待分摊项目选择" show-header="false" v-if="projectsDialog" :visible.sync="projectsDialog"
  348. :close-on-click-modal="false" customClass="customWidth" width="1000px">
  349. <el-select v-model="chosenProjects" multiple filterable clearable style="width:100%">
  350. <el-option v-for="item in allProjectList" :label="item.projectName" :key="item.id" :value="item.id"></el-option>
  351. </el-select>
  352. <div slot="footer" class="dialog-footer">
  353. <el-button type="default" @click="projectsDialog = false" >关闭</el-button>
  354. <el-button type="primary" @click="saveProjectSetting()" >确定</el-button>
  355. </div>
  356. </el-dialog>
  357. <el-dialog title="设置员工成本各项目占比" show-header="false" v-if="setPercentDialog" :visible.sync="setPercentDialog"
  358. :close-on-click-modal="false" customClass="customWidth" width="600px" >
  359. <div style="margin:0px 10px 10px 10px;">
  360. <span>选择员工</span>
  361. <el-select v-model="chosenNoReportUserIds" multiple filterable clearable style="width:330px;" collapse-tags>
  362. <el-option v-for="item in noReportUserList" :label="item.name" :key="item.id" :value="item.userId"></el-option>
  363. </el-select>
  364. <el-button @click="averageCost" >自动分摊</el-button>
  365. </div>
  366. <el-divider ></el-divider>
  367. <!--项目列表 -->
  368. <el-form v-model="curPercentVal" label-width="365px" style="margin-top:10px;">
  369. <div class="nameList">
  370. <el-form-item v-for="item in projectCols" :label="item.projectName" :key="item.projectId" >
  371. 占比: <el-input v-model="curPercentVal[item.projectId]" style="width:100px;" @input="updatePercentValue"></el-input>&nbsp;%
  372. </el-form-item>
  373. </div>
  374. <el-form-item >
  375. 总比例: {{totalPercent}}&nbsp;%
  376. </el-form-item>
  377. </el-form>
  378. <div slot="footer" class="dialog-footer">
  379. <el-button type="default" @click="setPercentDialog = false" >关闭</el-button>
  380. <el-button type="primary" @click="setPercentSetting()" >确定</el-button>
  381. </div>
  382. </el-dialog>
  383. </section>
  384. </template>
  385. <style scoped>
  386. .line {
  387. padding:10px;
  388. }
  389. .line span{
  390. font-size:18px;
  391. }
  392. .line span:nth-child(even){
  393. float:right;
  394. }
  395. </style>
  396. <script>
  397. import { error } from 'dingtalk-jsapi';
  398. import util from "../../common/js/util";
  399. export default {
  400. data() {
  401. return {
  402. exportMonth:null,
  403. exportDialog:false,
  404. headerCols:['monthCost','bonus', 'allowance', 'insuranceOld', 'insuranceMedical', 'insuranceLosejob', 'insuranceInjury', 'houseFund', 'customField1','customField2','customField3'],
  405. tblCols:[],
  406. costListRadio: 0,
  407. costSettingLoading: false,
  408. chosenNoReportUserIds:[],
  409. curPercentVal:{},
  410. setPercentDialog: false,
  411. chosenProjects:[],
  412. projectsDialog: false,
  413. projectCols:[],
  414. allProjectList:[],
  415. multipleSelection:[],
  416. userCostSettingList: [],
  417. settingDialog: false,
  418. radio:"全部人员",
  419. noReportUserList:[],
  420. allFinanceList:[],
  421. assignNoProUser: false,
  422. customFieldList:[],
  423. itemDialog: false,
  424. customCols:{},
  425. // showNPDialog: false,
  426. npUserList:[],
  427. hasNoProjectUsers: false,
  428. isUploading:false,
  429. importDialog: false,
  430. importParam:{syncUserCost:true, syncHistoryReport:true},
  431. user: JSON.parse(sessionStorage.getItem("user")),
  432. userDetailVisible: false,
  433. userDetail:{},
  434. date: null,
  435. tableHeight: 0,
  436. listLoading: false,
  437. list: [],
  438. addLoading: false,
  439. myChart: null,
  440. params: null,
  441. totalPercent:0,
  442. importVisible: false,
  443. shenhe: '',
  444. tabPosition: '0',
  445. reviewerVisible: false,
  446. reviewerRuleForm: {
  447. auditorId: ''
  448. },
  449. people: [],
  450. revaelse: '',
  451. reviewLis: [],
  452. ovReviewLis: [],
  453. xzImportVisible: false,
  454. xzList: []
  455. };
  456. },
  457. methods: {
  458. exportFinance() {
  459. this.isUploading = true;
  460. this.http.post('/finance/exportFinance', {
  461. date: this.exportMonth
  462. },res =>{
  463. this.isUploading = false;
  464. if(res.code == 'ok') {
  465. this.downloadByA({name:this.exportMonth+'财务数据.xls', url: res.data});
  466. }
  467. },error => {
  468. this.$message({
  469. message: error,
  470. type: "error"
  471. });
  472. })
  473. },
  474. arrter() {
  475. this.http.post('/user/getEmployeeList', {
  476. departmentId: '-1',
  477. pageIndex: 1,
  478. pageSize: 99999
  479. },res =>{
  480. if(res.code == 'ok') {
  481. this.people = res.data.records
  482. }
  483. },error => {
  484. this.$message({
  485. message: error,
  486. type: "error"
  487. });
  488. })
  489. },
  490. addreviewer() {
  491. this.http.post('/finance-auditor/get', {
  492. companyId: this.user.companyId
  493. },
  494. res => {
  495. if (res.code == "ok") {
  496. console.log(res.data, '数据')
  497. if(res.data) {
  498. this.reviewerRuleForm.auditorId = res.data.auditorId
  499. } else {
  500. this.reviewerRuleForm.auditorId = ''
  501. }
  502. }
  503. },error => {
  504. this.$message({
  505. message: error,
  506. type: "error"
  507. });
  508. }
  509. );
  510. },
  511. // 提交审核人
  512. submitreviewerRuleForm(formName) {
  513. this.$refs[formName].validate((valid) => {
  514. if (valid) {
  515. this.reviewerRuleForm.companyId = this.user.companyId
  516. this.http.post('/finance-auditor/save', this.reviewerRuleForm,
  517. res =>{
  518. if(res.code == 'ok') {
  519. this.$message({
  520. message: '操作成功',
  521. type: "success"
  522. });
  523. this.addreviewer()
  524. } else {
  525. this.$message({
  526. message: '操作失败',
  527. type: "error"
  528. });
  529. }
  530. },error => {
  531. this.$message({
  532. message: error,
  533. type: "error"
  534. });
  535. })
  536. this.reviewerVisible = false
  537. } else {
  538. return false;
  539. }
  540. });
  541. },
  542. handleCloses(done) {
  543. var formName = 'reviewerRuleForm'
  544. this.$refs[formName].resetFields();
  545. done()
  546. },
  547. // 审核
  548. audits() {
  549. this.shenhe = '导入审核'
  550. this.importVisible = true
  551. },
  552. switchCostList() {
  553. //已填日报的人员成本
  554. if (this.costListRadio == 1) {
  555. this.assignNoProUser=false;
  556. this.assignToProject();
  557. } else if (this.costListRadio == 2) {
  558. //全部人员成本
  559. this.assignNoProUser=true;
  560. this.assignToProject();
  561. }
  562. },
  563. getLastMonthSetting() {
  564. this.costSettingLoading = true;
  565. var dataArr = this.date.split('-');
  566. var year = dataArr[0];
  567. var month = dataArr[1];
  568. if (parseInt(month) == 1) {
  569. year = parseInt(year) -1;
  570. month = 12;
  571. } else {
  572. month = parseInt(month) -1;
  573. if (month < 10) {
  574. month = '0'+month;
  575. }
  576. }
  577. var lastMonth = year + '-' + month;
  578. this.http.post('/project-percentage/getMonthSetting', {ymonth: lastMonth},
  579. res => {
  580. this.costSettingLoading = false;
  581. if (res.code == "ok") {
  582. this.projectCols = res.data.financeProjects;
  583. this.allProjectList = res.data.allProjectList;
  584. this.userCostSettingList = res.data.userCostSetting;
  585. //上次如果没有配置过,需要初始化
  586. for (var i=0;i<this.noReportUserList.length; i++) {
  587. var rUser = this.noReportUserList[i];
  588. //检查当前列表中的无项目人员是否在之前的里面存在,如果不在需要加上去
  589. if (this.userCostSettingList.filter(c=>c.id == rUser.userId).length == 0) {
  590. var item = {name: rUser.name, id: rUser.userId};
  591. this.projectCols.forEach(p=>{
  592. item[p.projectId] = 0;
  593. });
  594. this.userCostSettingList.push(item);
  595. }
  596. }
  597. this.$nextTick(()=>{
  598. this.$refs.settingTable.doLayout();
  599. })
  600. } });
  601. },
  602. //获取当月的无项目工时人员的分配比例设置
  603. getMonthSetting() {
  604. this.costSettingLoading = true;
  605. this.http.post('/project-percentage/getMonthSetting', {ymonth: this.date},
  606. res => {
  607. this.costSettingLoading = false;
  608. if (res.code == "ok") {
  609. this.projectCols = res.data.financeProjects;
  610. this.allProjectList = res.data.allProjectList;
  611. this.userCostSettingList = res.data.userCostSetting;
  612. //上次如果没有配置过,需要初始化
  613. for (var i=0;i<this.noReportUserList.length; i++) {
  614. var rUser = this.noReportUserList[i];
  615. console.log('userId====='+rUser.userId);
  616. //检查当前列表中的无项目人员是否在之前的里面存在,如果不在需要加上去
  617. if (this.userCostSettingList.filter(c=>c.id == rUser.userId).length == 0) {
  618. var item = {name: rUser.name, id: rUser.userId};
  619. this.projectCols.forEach(p=>{
  620. item[p.projectId] = 0;
  621. });
  622. this.userCostSettingList.push(item);
  623. }
  624. }
  625. this.$nextTick(()=>{
  626. this.$refs.settingTable.doLayout();
  627. })
  628. } });
  629. },
  630. //提交无工时人员的分配设置
  631. saveMonthSetting() {
  632. //检查数据是否都分配到100%了,防止由于修改了项目列而导致之前的数据不正确的情况
  633. var errorList = this.userCostSettingList.filter(u=>{
  634. let totalPercent = 0.0;
  635. this.projectCols.forEach(p=>{
  636. totalPercent += parseFloat(u[p.projectId]);
  637. });
  638. totalPercent = totalPercent.toFixed(1);
  639. if (totalPercent != 100) {
  640. return true;
  641. } else {
  642. return false;
  643. }
  644. });
  645. if (errorList.length > 0) {
  646. var nameList = errorList.map(e=>e.name);
  647. this.$message({type:'error', message:'存在人员分配比例非100%: '+nameList});
  648. return;
  649. }
  650. this.http.post('/project-percentage/saveMonthSetting', {projectCols: JSON.stringify(this.projectCols),
  651. ymonth: this.date, userSettings: JSON.stringify(this.userCostSettingList)},
  652. res => {
  653. if (res.code == "ok") {
  654. this.$message({type:'success', message:'保存成功'});
  655. this.settingDialog = false;
  656. } else {
  657. this.$message({type:'error', message:'发生错误:'+res.msg});
  658. }});
  659. },
  660. updatePercentValue() {
  661. var total = 0.0;
  662. this.projectCols.forEach(p=>{
  663. total += parseFloat(this.curPercentVal[p.projectId]);
  664. })
  665. this.totalPercent = total.toFixed(1);
  666. this.$forceUpdate();
  667. },
  668. averageCost() {
  669. var avg = (100/this.projectCols.length).toFixed(1);
  670. //最后一个用100减去前面的总和,保证最终合计为100
  671. for (var i=0;i<this.projectCols.length; i++) {
  672. if (i < this.projectCols.length -1) {
  673. this.curPercentVal[this.projectCols[i].projectId] = avg;
  674. } else {
  675. this.curPercentVal[this.projectCols[i].projectId] = (100-avg*(this.projectCols.length-1)).toFixed(1);
  676. }
  677. }
  678. this.updatePercentValue();
  679. this.$forceUpdate();
  680. },
  681. setPercent(isBatch, row) {
  682. this.setPercentDialog = true;
  683. this.chosenNoReportUserIds = [];
  684. if (!isBatch) {
  685. this.chosenNoReportUserIds.push(row.id);
  686. //获取当前比例
  687. this.projectCols.forEach(p=>{
  688. this.curPercentVal[p.projectId] = row[p.projectId];
  689. });
  690. } else {
  691. //批量处理
  692. this.multipleSelection.forEach(m=>{
  693. this.chosenNoReportUserIds.push(m.id);
  694. })
  695. //批量时获取第一条的比例进行加载
  696. this.projectCols.forEach(p=>{
  697. this.curPercentVal[p.projectId] = this.multipleSelection[0][p.projectId];
  698. });
  699. }
  700. this.updatePercentValue();
  701. },
  702. //确认设置的项目列
  703. saveProjectSetting() {
  704. this.projectsDialog = false;
  705. this.projectCols = [];
  706. this.chosenProjects.forEach(c=>{
  707. var item = this.allProjectList.filter(a=>a.id == c)[0];
  708. this.projectCols.push({projectId: item.id, projectName: item.projectName, projectCode: item.projectCode});
  709. });
  710. this.$nextTick(()=>{
  711. this.$refs.settingTable.doLayout();
  712. })
  713. },
  714. handleProjectSelectionChange(val) {
  715. this.projectSelection = val;
  716. },
  717. showSelectProjectDialog() {
  718. //设置选中状态
  719. this.chosenProjects = [];
  720. this.projectCols.forEach(item=>{
  721. this.chosenProjects.push(item.projectId);
  722. })
  723. this.projectsDialog = true;
  724. },
  725. setPercentSetting() {
  726. //检测是否填写的情况下,是否达到100%
  727. if (this.totalPercent != 100) {
  728. this.$message({
  729. message: '分配比例之和必须是100%',
  730. type: "error"
  731. });
  732. return;
  733. }
  734. this.setPercentDialog = false;
  735. this.chosenNoReportUserIds.forEach(u=>{
  736. var targetU = this.userCostSettingList.filter(a=>a.id == u)[0];
  737. //遍历项目
  738. this.projectCols.forEach(p=>{
  739. targetU[p.projectId] = this.curPercentVal[p.projectId];
  740. })
  741. });
  742. this.userCostSettingList.splice(1,0);
  743. },
  744. showSettingDialog() {
  745. this.settingDialog = true;
  746. this.getMonthSetting();
  747. },
  748. handleSelectionChange(val) {
  749. this.multipleSelection = val;
  750. },
  751. switchList() {
  752. if (this.radio == '全部人员') {
  753. this.list = this.allFinanceList;
  754. } else {
  755. this.list = this.noReportUserList;
  756. }
  757. },
  758. downloadByA(row) {
  759. const a = document.createElement('a'); // 创建a标签
  760. a.setAttribute('download', row.name);// download属性
  761. console.log(row.url);
  762. a.setAttribute('href', row.url);// href链接
  763. a.click();// 自执行点击事件
  764. a.remove();
  765. },
  766. getTemplate() {
  767. this.http.post('/finance/getTemplate', {companyId: this.user.companyId},
  768. res => {
  769. if (res.code == "ok") {
  770. if (res.data.indexOf('xlsx') > 0) {
  771. this.downloadByA({name:'财务成本报表.xlsx', url:res.data});
  772. } else {
  773. this.downloadByA({name:'财务成本报表.xls', url:res.data});
  774. }
  775. }});
  776. },
  777. saveItems() {
  778. // let savefields = {
  779. // monthCost : this.customCols.monthCost,
  780. // bonus : this.customCols.bonus,
  781. // allowance : this.customCols.allowance,
  782. // insuranceOld : this.customCols.insuranceOld,
  783. // insuranceMedical : this.customCols.insuranceMedical,
  784. // insuranceLosejob : this.customCols.insuranceLosejob,
  785. // insuranceInjury : this.customCols.insuranceInjury,
  786. // houseFund : this.customCols.houseFund,
  787. // field1 : this.customCols.field1,
  788. // field2 : this.customCols.field2,
  789. // field3 : this.customCols.field3
  790. // }
  791. this.http.post('/finance-tblcuscol/save', this.customCols,
  792. res => {
  793. if (res.code == "ok") {
  794. this.itemDialog = false;
  795. this.getCustomColumn();
  796. }});
  797. this.$forceUpdate();
  798. },
  799. showItemDialog() {
  800. this.itemDialog = true;
  801. // this.customFieldList = {field1:null,field2:null, field3:null};
  802. // if (this.customCols.field1 !== undefined) {
  803. // this.customFieldList.field1 = this.customCols.field1;
  804. // } else if (this.customCols.field2 !== undefined) {
  805. // this.customFieldList.field2 = this.customCols.field2;
  806. // } else if (this.customCols.field3 !== undefined) {
  807. // this.customFieldList.field3 = this.customCols.field3;
  808. // }
  809. },
  810. //获取自定义的字段
  811. getCustomColumn() {
  812. this.http.post('/finance-tblcuscol/getAll', {companyId: this.user.companyId},
  813. res => {
  814. if (res.code == "ok") {
  815. this.customCols = res.data;
  816. this.tblCols = [];
  817. this.tblCols.push(this.customCols.monthCost);
  818. this.tblCols.push(this.customCols.bonus);
  819. this.tblCols.push(this.customCols.allowance);
  820. this.tblCols.push(this.customCols.insuranceOld);
  821. this.tblCols.push(this.customCols.insuranceMedical);
  822. this.tblCols.push(this.customCols.insuranceLosejob);
  823. this.tblCols.push(this.customCols.insuranceInjury);
  824. this.tblCols.push(this.customCols.houseFund);
  825. if (this.customCols.field1 != null) {
  826. this.tblCols.push(this.customCols.field1);
  827. }
  828. if (this.customCols.field2 != null) {
  829. this.tblCols.push(this.customCols.field2);
  830. }
  831. if (this.customCols.field3 != null) {
  832. this.tblCols.push(this.customCols.field3);
  833. }
  834. }});
  835. },
  836. // },
  837. // getProjects() {
  838. // this.http.post('/finance/getProjects', {companyId: this.user.companyId, yearMonth: this.date},
  839. // res => {
  840. // if (res.code == "ok") {
  841. // this.projectCols = res.data.financeProjects;
  842. // this.allProjectList = res.data.allProjectList;
  843. // }});
  844. // },
  845. // showNoProjectUsers() {
  846. // this.showNPDialog = true;
  847. // this.http.post('/finance/getNoProjectUsers', {yearMonth: this.date},
  848. // res => {
  849. // if (res.code == "ok") {
  850. // this.npUserList = res.data;
  851. // }});
  852. // },
  853. assignToProject(){
  854. var _this = this;
  855. this.http.post('/finance/getTimeCost', {yearMonth: this.date, assignNoProUser: this.assignNoProUser},
  856. res => {
  857. if (res.code == "ok") {
  858. var xList = [], yList = [], list = res.data.costList,
  859. totalMoneyCost = res.data.totalMoneyCost;
  860. var nopCost = 0;
  861. if (res.data.noProjectItem.project != null) {
  862. this.hasNoProjectUsers = true;
  863. nopCost = res.data.noProjectItem.cost;
  864. } else {
  865. this.hasNoProjectUsers = false;
  866. }
  867. for(var i in list) {
  868. xList.push(list[i].project);
  869. yList.push({
  870. "value": list[i].cost,
  871. "id": list[i].id,
  872. "time": list[i].workingTime
  873. });
  874. }
  875. var myChart = echarts.init(document.getElementById("container"));
  876. _this.myChart = myChart;
  877. var option = {
  878. title: {
  879. text: this.assignNoProUser?'成本总计 ' + totalMoneyCost + '元'
  880. +(this.hasNoProjectUsers?",含无项目人员成本 " + nopCost+"元 ":"")
  881. :'成本总计 ' + totalMoneyCost + '元',
  882. left:'left',
  883. },
  884. // 工具箱
  885. toolbox: {
  886. show: true,
  887. feature:{
  888. saveAsImage:{
  889. show:true
  890. },
  891. restore:{
  892. show:true
  893. },
  894. magicType:{
  895. type:['line','bar']
  896. },
  897. }
  898. },
  899. tooltip:{
  900. trigger:'axis',
  901. formatter: function (params,ticket,callback) {
  902. var res = params[0].name + "<br/>工作成本"+" : " + params[0].data.value
  903. + "元 <br/>工作时长"+" : " + params[0].data.time + "小时";
  904. _this.params = params;
  905. return res;
  906. }
  907. },
  908. xAxis: {
  909. data: xList,
  910. axisLabel: {
  911. interval:0,rotate:20
  912. }
  913. },
  914. yAxis: [{
  915. type : 'value',
  916. axisLabel: {
  917. formatter:'{value} (元)'
  918. }
  919. }],
  920. series: [{
  921. name: '工作时长(h)',
  922. type: 'bar',
  923. barMaxWidth: 30,
  924. data: yList,
  925. }]
  926. };
  927. option && myChart.setOption(option,{notMerge: true});
  928. // myChart.getZr().on('click', params => {
  929. // const pointInPixel = [params.offsetX, params.offsetY];
  930. // if (myChart.containPixel('grid', pointInPixel)) {
  931. // console.log(_this.params)
  932. // if(_this.radio=='项目') {
  933. // _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name);
  934. // }
  935. // }
  936. // });
  937. } else {
  938. this.$message({
  939. message: res.msg,
  940. type: "error"
  941. });
  942. }
  943. },
  944. error => {
  945. this.$message({
  946. message: error,
  947. type: "error"
  948. });
  949. });
  950. },
  951. //导出财务数据
  952. exportData() {
  953. this.listLoading = true;
  954. this.http.post('/finance/exportData', {
  955. date: this.date, assignNoProUser: this.assignNoProUser
  956. },
  957. res => {
  958. this.listLoading = false;
  959. if (res.code == "ok") {
  960. var aTag = document.createElement('a');
  961. aTag.download = "财务成本统计.xls";
  962. aTag.href = res.data;
  963. aTag.click();
  964. } else {
  965. this.$message({
  966. message: res.msg,
  967. type: "error"
  968. });
  969. }
  970. },
  971. error => {
  972. this.listLoading = false;
  973. this.$message({
  974. message: error,
  975. type: "error"
  976. });
  977. });
  978. },
  979. getSummaries(param) {
  980. const { columns, data } = param;
  981. const sums = [];
  982. columns.forEach((column, index) => {
  983. if (index === 0) {
  984. sums[index] = '总价';
  985. return;
  986. }
  987. const values = data.map(item => Number(item[column.property]));
  988. if (!values.every(value => isNaN(value))) {
  989. sums[index] = values.reduce((prev, curr) => {
  990. const value = Number(curr);
  991. if (!isNaN(value)) {
  992. return prev + curr;
  993. } else {
  994. return prev;
  995. }
  996. }, 0);
  997. sums[index] += ' 元';
  998. } else {
  999. sums[index] = 'N/A';
  1000. }
  1001. });
  1002. return sums;
  1003. },
  1004. changeMonth() {
  1005. //改变月份
  1006. this.getList();
  1007. this.assignToProject();
  1008. this.getMonths()
  1009. },
  1010. // 批量导入人员
  1011. importFinance(item) {
  1012. //首先判断文件类型
  1013. let str = item.file.name.split(".");
  1014. let format = str[str.length - 1];
  1015. if (format != "xls" && format != "xlsx") {
  1016. this.$message({
  1017. message: "请选择.xls或.xlsx文件",
  1018. type: "error"
  1019. });
  1020. } else {
  1021. this.listLoading = true;
  1022. let formData = new FormData();
  1023. formData.append("file", item.file);
  1024. formData.append("companyId", this.user.companyId);
  1025. formData.append("yearMonth", this.date);
  1026. formData.append("syncUserCost", this.importParam.syncUserCost);
  1027. formData.append("syncHistoryReport", this.importParam.syncHistoryReport);
  1028. this.isUploading = true;
  1029. let urls = ''
  1030. if(this.user.timeType.financeAudit == '1') {
  1031. urls = '/finance-import/submitImport'
  1032. } else {
  1033. urls = '/finance/importData'
  1034. }
  1035. // this.http.uploadFile('/finance/importData', formData,
  1036. this.http.uploadFile(urls, formData,
  1037. res => {
  1038. console.log(this.user.timeType.financeAudit, '看看数据')
  1039. this.$refs.upload.clearFiles();
  1040. this.listLoading = false;
  1041. this.isUploading = false;
  1042. if (res.code == "ok") {
  1043. if (this.user.timeType.financeAudit == 1 ) {
  1044. this.$message({
  1045. message: '导入成功,请等待审核',
  1046. type: "warning"
  1047. });
  1048. this.getMonths();
  1049. } else {
  1050. this.$message({
  1051. message: '导入成功',
  1052. type: "success"
  1053. });
  1054. }
  1055. this.importDialog = false;
  1056. //重新读取列表
  1057. this.getList();
  1058. } else {
  1059. this.$message({
  1060. message: res.msg,
  1061. type: "error"
  1062. });
  1063. }
  1064. },
  1065. error => {
  1066. this.$refs.upload.clearFiles();
  1067. this.listLoading = false;
  1068. this.$message({
  1069. message: error,
  1070. type: "error"
  1071. });
  1072. });
  1073. }
  1074. },
  1075. // 导入提交审核
  1076. // submitReview(formData) {
  1077. // this.http.uploadFile(' /finance-import/submitImport', formData,
  1078. // res => {
  1079. // if (res.code == "ok") {
  1080. // console.log(res.data, '来的数据')
  1081. // } else {
  1082. // this.$message({
  1083. // message: res.msg,
  1084. // type: "error"
  1085. // });
  1086. // }
  1087. // },
  1088. // error => {
  1089. // this.$refs.upload.clearFiles();
  1090. // this.listLoading = false;
  1091. // this.$message({
  1092. // message: error,
  1093. // type: "error"
  1094. // });
  1095. // });
  1096. // },
  1097. //获取项目列表
  1098. getList() {
  1099. this.listLoading = true;
  1100. this.http.post('/finance/getByMonth', {
  1101. companyId: this.user.companyId,
  1102. yearMonth: this.date
  1103. },
  1104. res => {
  1105. this.listLoading = false;
  1106. if (res.code == "ok") {
  1107. var list = res.data;
  1108. this.allFinanceList = list;
  1109. this.list = this.allFinanceList;
  1110. this.noReportUserList = list.filter(r=>r.hasReport == 0);
  1111. } else {
  1112. this.$message({
  1113. message: res.msg,
  1114. type: "error"
  1115. });
  1116. }
  1117. },
  1118. error => {
  1119. this.listLoading = false;
  1120. this.$message({
  1121. message: error,
  1122. type: "error"
  1123. });
  1124. });
  1125. },
  1126. // 获取当月的审核状态
  1127. getMonths() {
  1128. this.http.post('/finance-import/getStatus', {
  1129. companyId: this.user.companyId,
  1130. yearMonth: this.date
  1131. },
  1132. res => {
  1133. this.listLoading = false;
  1134. if (res.code == "ok") {
  1135. console.log(res.data, '审核状态')
  1136. if(res.data) {
  1137. if(res.data.state == '0') {
  1138. this.revaelse = '待审核'
  1139. this.tabPosition = '0'
  1140. } else if(res.data.state == '1') {
  1141. this.revaelse = '审核记录'
  1142. this.tabPosition = '1'
  1143. }else if (res.data.state == '2') {
  1144. this.revaelse = '已驳回'
  1145. this.tabPosition = '2'
  1146. } else if (res.data.state == '3') {
  1147. this.revaelse = '已撤销'
  1148. this.tabPosition = '-1'
  1149. }
  1150. this.getReviewList()
  1151. } else {
  1152. this.revaelse = ''
  1153. }
  1154. } else {
  1155. this.$message({
  1156. message: res.msg,
  1157. type: "error"
  1158. });
  1159. }
  1160. },
  1161. error => {
  1162. this.listLoading = false;
  1163. this.$message({
  1164. message: error,
  1165. type: "error"
  1166. });
  1167. });
  1168. },
  1169. // 获取审核列表
  1170. getReviewList() {
  1171. this.http.post('/finance-import/list', {
  1172. companyId: this.user.companyId,
  1173. },
  1174. res => {
  1175. if (res.code == "ok") {
  1176. console.log(res.data, '拿到的数据')
  1177. this.ovReviewLis = res.data
  1178. if(this.tabPosition == 0) {
  1179. this.reviewLis = res.data.pendingList
  1180. } else if(this.tabPosition == 1) {
  1181. this.reviewLis = res.data.passList
  1182. } else if(this.tabPosition == 2) {
  1183. this.reviewLis = res.data.rejectList
  1184. } else {
  1185. this.reviewLis = res.data.cancelList
  1186. }
  1187. console.log(this.reviewLis, '数据')
  1188. } else {
  1189. this.$message({
  1190. message: res.msg,
  1191. type: "error"
  1192. });
  1193. }
  1194. },
  1195. error => {
  1196. this.$message({
  1197. message: error,
  1198. type: "error"
  1199. });
  1200. });
  1201. },
  1202. // 操作数据
  1203. operationalData () {
  1204. var sss = this.ovReviewLis
  1205. if(this.tabPosition == 0) {
  1206. this.reviewLis = sss.pendingList
  1207. } else if(this.tabPosition == 1) {
  1208. this.reviewLis = sss.passList
  1209. } else if(this.tabPosition == 2) {
  1210. this.reviewLis = sss.rejectList
  1211. } else {
  1212. this.reviewLis = sss.cancelList
  1213. }
  1214. console.log(this.reviewLis, '数据')
  1215. },
  1216. // 审核操作
  1217. operationList(zhi, id) {
  1218. let urls
  1219. if(zhi == 0) {
  1220. urls = '/finance-import/agree'
  1221. } else if(zhi == 1){
  1222. urls = '/finance-import/deny'
  1223. } else {
  1224. urls = '/finance-import/cancel'
  1225. }
  1226. this.http.post(urls, {
  1227. id: id,
  1228. },
  1229. res => {
  1230. if (res.code == "ok") {
  1231. this.$message({
  1232. message: '操作成功',
  1233. type: "success"
  1234. });
  1235. this.getReviewList()
  1236. } else {
  1237. this.$message({
  1238. message: res.msg,
  1239. type: "error"
  1240. });
  1241. }
  1242. },
  1243. error => {
  1244. this.$message({
  1245. message: error,
  1246. type: "error"
  1247. });
  1248. });
  1249. },
  1250. // 获取薪资上传记录
  1251. xzjl() {
  1252. this.http.post('/finance-import/list', {
  1253. companyId: this.user.companyId,
  1254. // pageIndex:1,
  1255. // pageSize: 9999
  1256. },
  1257. res => {
  1258. if (res.code == "ok") {
  1259. console.log('123',res.data)
  1260. this.xzList = res.data.passList
  1261. } else {
  1262. this.$message({
  1263. message: res.msg,
  1264. type: "error"
  1265. });
  1266. }
  1267. },
  1268. error => {
  1269. this.$message({
  1270. message: error,
  1271. type: "error"
  1272. });
  1273. });
  1274. }
  1275. },
  1276. created() {
  1277. var d = new Date();
  1278. this.date = d.getFullYear() +'-'+ ((d.getMonth()+1) < 10? '0'+(d.getMonth()+1):d.getMonth()+1);
  1279. },
  1280. mounted() {
  1281. let height = window.innerHeight;
  1282. this.tableHeight = height - 245;
  1283. const that = this;
  1284. window.onresize = function temp() {
  1285. that.tableHeight = window.innerHeight - 245;
  1286. };
  1287. this.getCustomColumn();
  1288. this.getList();
  1289. // this.getProjects();
  1290. this.addreviewer();
  1291. this.arrter()
  1292. this.getMonths()
  1293. },
  1294. updated() {
  1295. this.$nextTick(() => {
  1296. this.$refs['table'].doLayout();
  1297. })
  1298. }
  1299. };
  1300. </script>
  1301. <style lang="scss" scoped>
  1302. .nameList {
  1303. height: 400px;
  1304. overflow: auto;
  1305. }
  1306. </style>