finance.vue 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415
  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. <el-button @click="intoAmortizationRatio">导入分摊比例</el-button>
  324. </div>
  325. <el-table :data="userCostSettingList" highlight-current-row v-loading="costSettingLoading"
  326. ref="settingTable" @selection-change="handleSelectionChange"
  327. :height="400" style="width: 100%;">
  328. <el-table-column type="selection" width="55"></el-table-column>
  329. <el-table-column prop="name" label="姓名" sortable width="90" fixed="left"></el-table-column>
  330. <el-table-column :label="item.projectName" v-for="(item) in projectCols" width="180" size="small"
  331. :key="item.id" align="center">
  332. <template slot-scope="scope">
  333. <span>{{scope.row[item.projectId]}}</span>%
  334. </template>
  335. </el-table-column>
  336. <el-table-column label="设置比例" width="80" fixed="right">
  337. <template slot-scope="scope">
  338. <el-button size="small" @click="setPercent(false,scope.row)">设置</el-button>
  339. </template>
  340. </el-table-column>
  341. </el-table>
  342. </div>
  343. <div slot="footer" class="dialog-footer">
  344. <el-button type="primary" @click="settingDialog = false" >关闭</el-button>
  345. <el-button type="primary" @click="saveMonthSetting()" >保存</el-button>
  346. </div>
  347. </el-dialog>
  348. <el-dialog title="待分摊项目选择" show-header="false" v-if="projectsDialog" :visible.sync="projectsDialog"
  349. :close-on-click-modal="false" customClass="customWidth" width="1000px">
  350. <el-select v-model="chosenProjects" multiple filterable clearable style="width:100%">
  351. <el-option v-for="item in allProjectList" :label="item.projectName" :key="item.id" :value="item.id"></el-option>
  352. </el-select>
  353. <div slot="footer" class="dialog-footer">
  354. <el-button type="default" @click="projectsDialog = false" >关闭</el-button>
  355. <el-button type="primary" @click="saveProjectSetting()" >确定</el-button>
  356. </div>
  357. </el-dialog>
  358. <el-dialog title="导入分摊比例数据" v-if="intoAmortizationDialog" :visible.sync="intoAmortizationDialog" customClass="customWidth" width="500px">
  359. <p>1. 下载
  360. <el-link type="primary" style="margin-left:5px;" :underline="false" href="./upload/员工项目分摊比例模板2.xlsx" download="员工项目分摊比例导入模板.xlsx">员工项目分摊比例模板.xlsx</el-link>
  361. </p>
  362. <p>2. 填写excel模板,请确保模板中的项目和人员已添加到系统中。</p>
  363. <p style="display: flex;justify-content: center;">
  364. <el-upload ref="upload" action="#" :limit="1" :http-request="batchImportData" :show-file-list="false">
  365. <el-button type="primary" :underline="false" :loading="importingData">开始导入</el-button>
  366. </el-upload>
  367. </p>
  368. </el-dialog>
  369. <el-dialog title="设置员工成本各项目占比" show-header="false" v-if="setPercentDialog" :visible.sync="setPercentDialog"
  370. :close-on-click-modal="false" customClass="customWidth" width="600px" >
  371. <div style="margin:0px 10px 10px 10px;">
  372. <span>选择员工</span>
  373. <el-select v-model="chosenNoReportUserIds" multiple filterable clearable style="width:330px;" collapse-tags>
  374. <el-option v-for="item in noReportUserList" :label="item.name" :key="item.id" :value="item.userId"></el-option>
  375. </el-select>
  376. <el-button @click="averageCost" >自动分摊</el-button>
  377. </div>
  378. <el-divider ></el-divider>
  379. <!--项目列表 -->
  380. <el-form v-model="curPercentVal" label-width="365px" style="margin-top:10px;">
  381. <div class="nameList">
  382. <el-form-item v-for="item in projectCols" :label="item.projectName" :key="item.projectId" >
  383. 占比: <el-input v-model="curPercentVal[item.projectId]" style="width:100px;" @input="updatePercentValue"></el-input>&nbsp;%
  384. </el-form-item>
  385. </div>
  386. <el-form-item >
  387. 总比例: {{totalPercent}}&nbsp;%
  388. </el-form-item>
  389. </el-form>
  390. <div slot="footer" class="dialog-footer">
  391. <el-button type="default" @click="setPercentDialog = false" >关闭</el-button>
  392. <el-button type="primary" @click="setPercentSetting()" >确定</el-button>
  393. </div>
  394. </el-dialog>
  395. </section>
  396. </template>
  397. <style scoped>
  398. .line {
  399. padding:10px;
  400. }
  401. .line span{
  402. font-size:18px;
  403. }
  404. .line span:nth-child(even){
  405. float:right;
  406. }
  407. </style>
  408. <script>
  409. import { error } from 'dingtalk-jsapi';
  410. import util from "../../common/js/util";
  411. export default {
  412. data() {
  413. return {
  414. exportMonth:null,
  415. exportDialog:false,
  416. headerCols:['monthCost','bonus', 'allowance', 'insuranceOld', 'insuranceMedical', 'insuranceLosejob', 'insuranceInjury', 'houseFund', 'customField1','customField2','customField3'],
  417. tblCols:[],
  418. costListRadio: 0,
  419. costSettingLoading: false,
  420. chosenNoReportUserIds:[],
  421. curPercentVal:{},
  422. setPercentDialog: false,
  423. chosenProjects:[],
  424. projectsDialog: false,
  425. projectCols:[],
  426. allProjectList:[],
  427. multipleSelection:[],
  428. userCostSettingList: [],
  429. settingDialog: false,
  430. radio:"全部人员",
  431. noReportUserList:[],
  432. allFinanceList:[],
  433. assignNoProUser: false,
  434. customFieldList:[],
  435. itemDialog: false,
  436. customCols:{},
  437. // showNPDialog: false,
  438. npUserList:[],
  439. hasNoProjectUsers: false,
  440. isUploading:false,
  441. importDialog: false,
  442. importParam:{syncUserCost:true, syncHistoryReport:true},
  443. user: JSON.parse(sessionStorage.getItem("user")),
  444. userDetailVisible: false,
  445. userDetail:{},
  446. date: null,
  447. tableHeight: 0,
  448. listLoading: false,
  449. list: [],
  450. addLoading: false,
  451. myChart: null,
  452. params: null,
  453. totalPercent:0,
  454. importVisible: false,
  455. shenhe: '',
  456. tabPosition: '0',
  457. reviewerVisible: false,
  458. reviewerRuleForm: {
  459. auditorId: ''
  460. },
  461. people: [],
  462. revaelse: '',
  463. reviewLis: [],
  464. ovReviewLis: [],
  465. xzImportVisible: false,
  466. xzList: [],
  467. intoAmortizationDialog : false ,
  468. importingData: false,
  469. };
  470. },
  471. methods: {
  472. exportFinance() {
  473. this.isUploading = true;
  474. this.http.post('/finance/exportFinance', {
  475. date: this.exportMonth
  476. },res =>{
  477. this.isUploading = false;
  478. if(res.code == 'ok') {
  479. this.downloadByA({name:this.exportMonth+'财务数据.xls', url: res.data});
  480. }
  481. },error => {
  482. this.$message({
  483. message: error,
  484. type: "error"
  485. });
  486. })
  487. },
  488. arrter() {
  489. this.http.post('/user/getEmployeeList', {
  490. departmentId: '-1',
  491. pageIndex: 1,
  492. pageSize: 99999
  493. },res =>{
  494. if(res.code == 'ok') {
  495. this.people = res.data.records
  496. }
  497. },error => {
  498. this.$message({
  499. message: error,
  500. type: "error"
  501. });
  502. })
  503. },
  504. addreviewer() {
  505. this.http.post('/finance-auditor/get', {
  506. companyId: this.user.companyId
  507. },
  508. res => {
  509. if (res.code == "ok") {
  510. console.log(res.data, '数据')
  511. if(res.data) {
  512. this.reviewerRuleForm.auditorId = res.data.auditorId
  513. } else {
  514. this.reviewerRuleForm.auditorId = ''
  515. }
  516. }
  517. },error => {
  518. this.$message({
  519. message: error,
  520. type: "error"
  521. });
  522. }
  523. );
  524. },
  525. // 提交审核人
  526. submitreviewerRuleForm(formName) {
  527. this.$refs[formName].validate((valid) => {
  528. if (valid) {
  529. this.reviewerRuleForm.companyId = this.user.companyId
  530. this.http.post('/finance-auditor/save', this.reviewerRuleForm,
  531. res =>{
  532. if(res.code == 'ok') {
  533. this.$message({
  534. message: '操作成功',
  535. type: "success"
  536. });
  537. this.addreviewer()
  538. } else {
  539. this.$message({
  540. message: '操作失败',
  541. type: "error"
  542. });
  543. }
  544. },error => {
  545. this.$message({
  546. message: error,
  547. type: "error"
  548. });
  549. })
  550. this.reviewerVisible = false
  551. } else {
  552. return false;
  553. }
  554. });
  555. },
  556. handleCloses(done) {
  557. var formName = 'reviewerRuleForm'
  558. this.$refs[formName].resetFields();
  559. done()
  560. },
  561. // 审核
  562. audits() {
  563. this.shenhe = '导入审核'
  564. this.importVisible = true
  565. },
  566. switchCostList() {
  567. //已填日报的人员成本
  568. if (this.costListRadio == 1) {
  569. this.assignNoProUser=false;
  570. this.assignToProject();
  571. } else if (this.costListRadio == 2) {
  572. //全部人员成本
  573. this.assignNoProUser=true;
  574. this.assignToProject();
  575. }
  576. },
  577. getLastMonthSetting() {
  578. this.costSettingLoading = true;
  579. var dataArr = this.date.split('-');
  580. var year = dataArr[0];
  581. var month = dataArr[1];
  582. if (parseInt(month) == 1) {
  583. year = parseInt(year) -1;
  584. month = 12;
  585. } else {
  586. month = parseInt(month) -1;
  587. if (month < 10) {
  588. month = '0'+month;
  589. }
  590. }
  591. var lastMonth = year + '-' + month;
  592. this.http.post('/project-percentage/getMonthSetting', {ymonth: lastMonth},
  593. res => {
  594. this.costSettingLoading = false;
  595. if (res.code == "ok") {
  596. this.projectCols = res.data.financeProjects;
  597. this.allProjectList = res.data.allProjectList;
  598. this.userCostSettingList = res.data.userCostSetting;
  599. //上次如果没有配置过,需要初始化
  600. for (var i=0;i<this.noReportUserList.length; i++) {
  601. var rUser = this.noReportUserList[i];
  602. //检查当前列表中的无项目人员是否在之前的里面存在,如果不在需要加上去
  603. if (this.userCostSettingList.filter(c=>c.id == rUser.userId).length == 0) {
  604. var item = {name: rUser.name, id: rUser.userId};
  605. this.projectCols.forEach(p=>{
  606. item[p.projectId] = 0;
  607. });
  608. this.userCostSettingList.push(item);
  609. }
  610. }
  611. this.$nextTick(()=>{
  612. this.$refs.settingTable.doLayout();
  613. })
  614. } });
  615. },
  616. //获取当月的无项目工时人员的分配比例设置
  617. getMonthSetting() {
  618. this.costSettingLoading = true;
  619. this.http.post('/project-percentage/getMonthSetting', {ymonth: this.date},
  620. res => {
  621. this.costSettingLoading = false;
  622. if (res.code == "ok") {
  623. this.projectCols = res.data.financeProjects;
  624. this.allProjectList = res.data.allProjectList;
  625. this.userCostSettingList = res.data.userCostSetting;
  626. //上次如果没有配置过,需要初始化
  627. for (var i=0;i<this.noReportUserList.length; i++) {
  628. var rUser = this.noReportUserList[i];
  629. console.log('userId====='+rUser.userId);
  630. //检查当前列表中的无项目人员是否在之前的里面存在,如果不在需要加上去
  631. if (this.userCostSettingList.filter(c=>c.id == rUser.userId).length == 0) {
  632. var item = {name: rUser.name, id: rUser.userId};
  633. this.projectCols.forEach(p=>{
  634. item[p.projectId] = 0;
  635. });
  636. this.userCostSettingList.push(item);
  637. }
  638. }
  639. this.$nextTick(()=>{
  640. this.$refs.settingTable.doLayout();
  641. })
  642. } });
  643. },
  644. //提交无工时人员的分配设置
  645. saveMonthSetting() {
  646. //检查数据是否都分配到100%了,防止由于修改了项目列而导致之前的数据不正确的情况
  647. var errorList = this.userCostSettingList.filter(u=>{
  648. let totalPercent = 0.0;
  649. this.projectCols.forEach(p=>{
  650. totalPercent += parseFloat(u[p.projectId]);
  651. });
  652. totalPercent = totalPercent.toFixed(1);
  653. if (totalPercent != 100) {
  654. return true;
  655. } else {
  656. return false;
  657. }
  658. });
  659. if (errorList.length > 0) {
  660. var nameList = errorList.map(e=>e.name);
  661. this.$message({type:'error', message:'存在人员分配比例非100%: '+nameList});
  662. return;
  663. }
  664. this.http.post('/project-percentage/saveMonthSetting', {projectCols: JSON.stringify(this.projectCols),
  665. ymonth: this.date, userSettings: JSON.stringify(this.userCostSettingList)},
  666. res => {
  667. if (res.code == "ok") {
  668. this.$message({type:'success', message:'保存成功'});
  669. this.settingDialog = false;
  670. } else {
  671. this.$message({type:'error', message:'发生错误:'+res.msg});
  672. }});
  673. },
  674. updatePercentValue() {
  675. var total = 0.0;
  676. this.projectCols.forEach(p=>{
  677. total += parseFloat(this.curPercentVal[p.projectId]);
  678. })
  679. this.totalPercent = total.toFixed(1);
  680. this.$forceUpdate();
  681. },
  682. averageCost() {
  683. var avg = (100/this.projectCols.length).toFixed(1);
  684. //最后一个用100减去前面的总和,保证最终合计为100
  685. for (var i=0;i<this.projectCols.length; i++) {
  686. if (i < this.projectCols.length -1) {
  687. this.curPercentVal[this.projectCols[i].projectId] = avg;
  688. } else {
  689. this.curPercentVal[this.projectCols[i].projectId] = (100-avg*(this.projectCols.length-1)).toFixed(1);
  690. }
  691. }
  692. this.updatePercentValue();
  693. this.$forceUpdate();
  694. },
  695. setPercent(isBatch, row) {
  696. this.setPercentDialog = true;
  697. this.chosenNoReportUserIds = [];
  698. if (!isBatch) {
  699. this.chosenNoReportUserIds.push(row.id);
  700. //获取当前比例
  701. this.projectCols.forEach(p=>{
  702. this.curPercentVal[p.projectId] = row[p.projectId];
  703. });
  704. } else {
  705. //批量处理
  706. this.multipleSelection.forEach(m=>{
  707. this.chosenNoReportUserIds.push(m.id);
  708. })
  709. //批量时获取第一条的比例进行加载
  710. this.projectCols.forEach(p=>{
  711. this.curPercentVal[p.projectId] = this.multipleSelection[0][p.projectId];
  712. });
  713. }
  714. this.updatePercentValue();
  715. },
  716. //确认设置的项目列
  717. saveProjectSetting() {
  718. this.projectsDialog = false;
  719. this.projectCols = [];
  720. this.chosenProjects.forEach(c=>{
  721. var item = this.allProjectList.filter(a=>a.id == c)[0];
  722. this.projectCols.push({projectId: item.id, projectName: item.projectName, projectCode: item.projectCode});
  723. });
  724. this.$nextTick(()=>{
  725. this.$refs.settingTable.doLayout();
  726. })
  727. },
  728. handleProjectSelectionChange(val) {
  729. this.projectSelection = val;
  730. },
  731. showSelectProjectDialog() {
  732. //设置选中状态
  733. this.chosenProjects = [];
  734. this.projectCols.forEach(item=>{
  735. this.chosenProjects.push(item.projectId);
  736. })
  737. this.projectsDialog = true;
  738. },
  739. setPercentSetting() {
  740. //检测是否填写的情况下,是否达到100%
  741. if (this.totalPercent != 100) {
  742. this.$message({
  743. message: '分配比例之和必须是100%',
  744. type: "error"
  745. });
  746. return;
  747. }
  748. this.setPercentDialog = false;
  749. this.chosenNoReportUserIds.forEach(u=>{
  750. var targetU = this.userCostSettingList.filter(a=>a.id == u)[0];
  751. //遍历项目
  752. this.projectCols.forEach(p=>{
  753. targetU[p.projectId] = this.curPercentVal[p.projectId];
  754. })
  755. });
  756. this.userCostSettingList.splice(1,0);
  757. },
  758. showSettingDialog() {
  759. this.settingDialog = true;
  760. this.getMonthSetting();
  761. },
  762. handleSelectionChange(val) {
  763. this.multipleSelection = val;
  764. },
  765. switchList() {
  766. if (this.radio == '全部人员') {
  767. this.list = this.allFinanceList;
  768. } else {
  769. this.list = this.noReportUserList;
  770. }
  771. },
  772. downloadByA(row) {
  773. const a = document.createElement('a'); // 创建a标签
  774. a.setAttribute('download', row.name);// download属性
  775. console.log(row.url);
  776. a.setAttribute('href', row.url);// href链接
  777. a.click();// 自执行点击事件
  778. a.remove();
  779. },
  780. getTemplate() {
  781. this.http.post('/finance/getTemplate', {companyId: this.user.companyId},
  782. res => {
  783. if (res.code == "ok") {
  784. if (res.data.indexOf('xlsx') > 0) {
  785. this.downloadByA({name:'财务成本报表.xlsx', url:res.data});
  786. } else {
  787. this.downloadByA({name:'财务成本报表.xls', url:res.data});
  788. }
  789. }});
  790. },
  791. saveItems() {
  792. // let savefields = {
  793. // monthCost : this.customCols.monthCost,
  794. // bonus : this.customCols.bonus,
  795. // allowance : this.customCols.allowance,
  796. // insuranceOld : this.customCols.insuranceOld,
  797. // insuranceMedical : this.customCols.insuranceMedical,
  798. // insuranceLosejob : this.customCols.insuranceLosejob,
  799. // insuranceInjury : this.customCols.insuranceInjury,
  800. // houseFund : this.customCols.houseFund,
  801. // field1 : this.customCols.field1,
  802. // field2 : this.customCols.field2,
  803. // field3 : this.customCols.field3
  804. // }
  805. this.http.post('/finance-tblcuscol/save', this.customCols,
  806. res => {
  807. if (res.code == "ok") {
  808. this.itemDialog = false;
  809. this.getCustomColumn();
  810. }});
  811. this.$forceUpdate();
  812. },
  813. showItemDialog() {
  814. this.itemDialog = true;
  815. // this.customFieldList = {field1:null,field2:null, field3:null};
  816. // if (this.customCols.field1 !== undefined) {
  817. // this.customFieldList.field1 = this.customCols.field1;
  818. // } else if (this.customCols.field2 !== undefined) {
  819. // this.customFieldList.field2 = this.customCols.field2;
  820. // } else if (this.customCols.field3 !== undefined) {
  821. // this.customFieldList.field3 = this.customCols.field3;
  822. // }
  823. },
  824. //获取自定义的字段
  825. getCustomColumn() {
  826. this.http.post('/finance-tblcuscol/getAll', {companyId: this.user.companyId},
  827. res => {
  828. if (res.code == "ok") {
  829. this.customCols = res.data;
  830. this.tblCols = [];
  831. this.tblCols.push(this.customCols.monthCost);
  832. this.tblCols.push(this.customCols.bonus);
  833. this.tblCols.push(this.customCols.allowance);
  834. this.tblCols.push(this.customCols.insuranceOld);
  835. this.tblCols.push(this.customCols.insuranceMedical);
  836. this.tblCols.push(this.customCols.insuranceLosejob);
  837. this.tblCols.push(this.customCols.insuranceInjury);
  838. this.tblCols.push(this.customCols.houseFund);
  839. if (this.customCols.field1 != null) {
  840. this.tblCols.push(this.customCols.field1);
  841. }
  842. if (this.customCols.field2 != null) {
  843. this.tblCols.push(this.customCols.field2);
  844. }
  845. if (this.customCols.field3 != null) {
  846. this.tblCols.push(this.customCols.field3);
  847. }
  848. }});
  849. },
  850. // },
  851. // getProjects() {
  852. // this.http.post('/finance/getProjects', {companyId: this.user.companyId, yearMonth: this.date},
  853. // res => {
  854. // if (res.code == "ok") {
  855. // this.projectCols = res.data.financeProjects;
  856. // this.allProjectList = res.data.allProjectList;
  857. // }});
  858. // },
  859. // showNoProjectUsers() {
  860. // this.showNPDialog = true;
  861. // this.http.post('/finance/getNoProjectUsers', {yearMonth: this.date},
  862. // res => {
  863. // if (res.code == "ok") {
  864. // this.npUserList = res.data;
  865. // }});
  866. // },
  867. assignToProject(){
  868. var _this = this;
  869. this.http.post('/finance/getTimeCost', {yearMonth: this.date, assignNoProUser: this.assignNoProUser},
  870. res => {
  871. if (res.code == "ok") {
  872. var xList = [], yList = [], list = res.data.costList,
  873. totalMoneyCost = res.data.totalMoneyCost;
  874. var nopCost = 0;
  875. if (res.data.noProjectItem.project != null) {
  876. this.hasNoProjectUsers = true;
  877. nopCost = res.data.noProjectItem.cost;
  878. } else {
  879. this.hasNoProjectUsers = false;
  880. }
  881. for(var i in list) {
  882. xList.push(list[i].project);
  883. yList.push({
  884. "value": list[i].cost,
  885. "id": list[i].id,
  886. "time": list[i].workingTime
  887. });
  888. }
  889. var myChart = echarts.init(document.getElementById("container"));
  890. _this.myChart = myChart;
  891. var option = {
  892. title: {
  893. text: this.assignNoProUser?'成本总计 ' + totalMoneyCost + '元'
  894. +(this.hasNoProjectUsers?",含无项目人员成本 " + nopCost+"元 ":"")
  895. :'成本总计 ' + totalMoneyCost + '元',
  896. left:'left',
  897. },
  898. // 工具箱
  899. toolbox: {
  900. show: true,
  901. feature:{
  902. saveAsImage:{
  903. show:true
  904. },
  905. restore:{
  906. show:true
  907. },
  908. magicType:{
  909. type:['line','bar']
  910. },
  911. }
  912. },
  913. tooltip:{
  914. trigger:'axis',
  915. formatter: function (params,ticket,callback) {
  916. var res = params[0].name + "<br/>工作成本"+" : " + params[0].data.value
  917. + "元 <br/>工作时长"+" : " + params[0].data.time + "小时";
  918. _this.params = params;
  919. return res;
  920. }
  921. },
  922. xAxis: {
  923. data: xList,
  924. axisLabel: {
  925. interval:0,rotate:20
  926. }
  927. },
  928. yAxis: [{
  929. type : 'value',
  930. axisLabel: {
  931. formatter:'{value} (元)'
  932. }
  933. }],
  934. series: [{
  935. name: '工作时长(h)',
  936. type: 'bar',
  937. barMaxWidth: 30,
  938. data: yList,
  939. }]
  940. };
  941. option && myChart.setOption(option,{notMerge: true});
  942. // myChart.getZr().on('click', params => {
  943. // const pointInPixel = [params.offsetX, params.offsetY];
  944. // if (myChart.containPixel('grid', pointInPixel)) {
  945. // console.log(_this.params)
  946. // if(_this.radio=='项目') {
  947. // _this.$router.push("/cost/" + _this.params[0].data.id + "/" + _this.params[0].name);
  948. // }
  949. // }
  950. // });
  951. } else {
  952. this.$message({
  953. message: res.msg,
  954. type: "error"
  955. });
  956. }
  957. },
  958. error => {
  959. this.$message({
  960. message: error,
  961. type: "error"
  962. });
  963. });
  964. },
  965. //导出财务数据
  966. exportData() {
  967. this.listLoading = true;
  968. this.http.post('/finance/exportData', {
  969. date: this.date, assignNoProUser: this.assignNoProUser
  970. },
  971. res => {
  972. this.listLoading = false;
  973. if (res.code == "ok") {
  974. var aTag = document.createElement('a');
  975. aTag.download = "财务成本统计.xls";
  976. aTag.href = res.data;
  977. aTag.click();
  978. } else {
  979. this.$message({
  980. message: res.msg,
  981. type: "error"
  982. });
  983. }
  984. },
  985. error => {
  986. this.listLoading = false;
  987. this.$message({
  988. message: error,
  989. type: "error"
  990. });
  991. });
  992. },
  993. getSummaries(param) {
  994. const { columns, data } = param;
  995. const sums = [];
  996. columns.forEach((column, index) => {
  997. if (index === 0) {
  998. sums[index] = '总价';
  999. return;
  1000. }
  1001. const values = data.map(item => Number(item[column.property]));
  1002. if (!values.every(value => isNaN(value))) {
  1003. sums[index] = values.reduce((prev, curr) => {
  1004. const value = Number(curr);
  1005. if (!isNaN(value)) {
  1006. return prev + curr;
  1007. } else {
  1008. return prev;
  1009. }
  1010. }, 0);
  1011. sums[index] += ' 元';
  1012. } else {
  1013. sums[index] = 'N/A';
  1014. }
  1015. });
  1016. return sums;
  1017. },
  1018. changeMonth() {
  1019. //改变月份
  1020. this.getList();
  1021. this.assignToProject();
  1022. this.getMonths()
  1023. },
  1024. // 批量导入人员
  1025. importFinance(item) {
  1026. //首先判断文件类型
  1027. let str = item.file.name.split(".");
  1028. let format = str[str.length - 1];
  1029. if (format != "xls" && format != "xlsx") {
  1030. this.$message({
  1031. message: "请选择.xls或.xlsx文件",
  1032. type: "error"
  1033. });
  1034. } else {
  1035. this.listLoading = true;
  1036. let formData = new FormData();
  1037. formData.append("file", item.file);
  1038. formData.append("companyId", this.user.companyId);
  1039. formData.append("yearMonth", this.date);
  1040. formData.append("syncUserCost", this.importParam.syncUserCost);
  1041. formData.append("syncHistoryReport", this.importParam.syncHistoryReport);
  1042. this.isUploading = true;
  1043. let urls = ''
  1044. if(this.user.timeType.financeAudit == '1') {
  1045. urls = '/finance-import/submitImport'
  1046. } else {
  1047. urls = '/finance/importData'
  1048. }
  1049. // this.http.uploadFile('/finance/importData', formData,
  1050. this.http.uploadFile(urls, formData,
  1051. res => {
  1052. console.log(this.user.timeType.financeAudit, '看看数据')
  1053. this.$refs.upload.clearFiles();
  1054. this.listLoading = false;
  1055. this.isUploading = false;
  1056. if (res.code == "ok") {
  1057. if (this.user.timeType.financeAudit == 1 ) {
  1058. this.$message({
  1059. message: '导入成功,请等待审核',
  1060. type: "warning"
  1061. });
  1062. this.getMonths();
  1063. } else {
  1064. this.$message({
  1065. message: '导入成功',
  1066. type: "success"
  1067. });
  1068. }
  1069. this.importDialog = false;
  1070. //重新读取列表
  1071. this.getList();
  1072. } else {
  1073. this.$message({
  1074. message: res.msg,
  1075. type: "error"
  1076. });
  1077. }
  1078. },
  1079. error => {
  1080. this.$refs.upload.clearFiles();
  1081. this.listLoading = false;
  1082. this.$message({
  1083. message: error,
  1084. type: "error"
  1085. });
  1086. });
  1087. }
  1088. },
  1089. // 导入提交审核
  1090. // submitReview(formData) {
  1091. // this.http.uploadFile(' /finance-import/submitImport', formData,
  1092. // res => {
  1093. // if (res.code == "ok") {
  1094. // console.log(res.data, '来的数据')
  1095. // } else {
  1096. // this.$message({
  1097. // message: res.msg,
  1098. // type: "error"
  1099. // });
  1100. // }
  1101. // },
  1102. // error => {
  1103. // this.$refs.upload.clearFiles();
  1104. // this.listLoading = false;
  1105. // this.$message({
  1106. // message: error,
  1107. // type: "error"
  1108. // });
  1109. // });
  1110. // },
  1111. //获取项目列表
  1112. getList() {
  1113. this.listLoading = true;
  1114. this.http.post('/finance/getByMonth', {
  1115. companyId: this.user.companyId,
  1116. yearMonth: this.date
  1117. },
  1118. res => {
  1119. this.listLoading = false;
  1120. if (res.code == "ok") {
  1121. var list = res.data;
  1122. this.allFinanceList = list;
  1123. this.list = this.allFinanceList;
  1124. this.noReportUserList = list.filter(r=>r.hasReport == 0);
  1125. } else {
  1126. this.$message({
  1127. message: res.msg,
  1128. type: "error"
  1129. });
  1130. }
  1131. },
  1132. error => {
  1133. this.listLoading = false;
  1134. this.$message({
  1135. message: error,
  1136. type: "error"
  1137. });
  1138. });
  1139. },
  1140. // 获取当月的审核状态
  1141. getMonths() {
  1142. this.http.post('/finance-import/getStatus', {
  1143. companyId: this.user.companyId,
  1144. yearMonth: this.date
  1145. },
  1146. res => {
  1147. this.listLoading = false;
  1148. if (res.code == "ok") {
  1149. console.log(res.data, '审核状态')
  1150. if(res.data) {
  1151. if(res.data.state == '0') {
  1152. this.revaelse = '待审核'
  1153. this.tabPosition = '0'
  1154. } else if(res.data.state == '1') {
  1155. this.revaelse = '审核记录'
  1156. this.tabPosition = '1'
  1157. }else if (res.data.state == '2') {
  1158. this.revaelse = '已驳回'
  1159. this.tabPosition = '2'
  1160. } else if (res.data.state == '3') {
  1161. this.revaelse = '已撤销'
  1162. this.tabPosition = '-1'
  1163. }
  1164. this.getReviewList()
  1165. } else {
  1166. this.revaelse = ''
  1167. }
  1168. } else {
  1169. this.$message({
  1170. message: res.msg,
  1171. type: "error"
  1172. });
  1173. }
  1174. },
  1175. error => {
  1176. this.listLoading = false;
  1177. this.$message({
  1178. message: error,
  1179. type: "error"
  1180. });
  1181. });
  1182. },
  1183. // 获取审核列表
  1184. getReviewList() {
  1185. this.http.post('/finance-import/list', {
  1186. companyId: this.user.companyId,
  1187. },
  1188. res => {
  1189. if (res.code == "ok") {
  1190. console.log(res.data, '拿到的数据')
  1191. this.ovReviewLis = res.data
  1192. if(this.tabPosition == 0) {
  1193. this.reviewLis = res.data.pendingList
  1194. } else if(this.tabPosition == 1) {
  1195. this.reviewLis = res.data.passList
  1196. } else if(this.tabPosition == 2) {
  1197. this.reviewLis = res.data.rejectList
  1198. } else {
  1199. this.reviewLis = res.data.cancelList
  1200. }
  1201. console.log(this.reviewLis, '数据')
  1202. } else {
  1203. this.$message({
  1204. message: res.msg,
  1205. type: "error"
  1206. });
  1207. }
  1208. },
  1209. error => {
  1210. this.$message({
  1211. message: error,
  1212. type: "error"
  1213. });
  1214. });
  1215. },
  1216. // 操作数据
  1217. operationalData () {
  1218. var sss = this.ovReviewLis
  1219. if(this.tabPosition == 0) {
  1220. this.reviewLis = sss.pendingList
  1221. } else if(this.tabPosition == 1) {
  1222. this.reviewLis = sss.passList
  1223. } else if(this.tabPosition == 2) {
  1224. this.reviewLis = sss.rejectList
  1225. } else {
  1226. this.reviewLis = sss.cancelList
  1227. }
  1228. console.log(this.reviewLis, '数据')
  1229. },
  1230. // 审核操作
  1231. operationList(zhi, id) {
  1232. let urls
  1233. if(zhi == 0) {
  1234. urls = '/finance-import/agree'
  1235. } else if(zhi == 1){
  1236. urls = '/finance-import/deny'
  1237. } else {
  1238. urls = '/finance-import/cancel'
  1239. }
  1240. this.http.post(urls, {
  1241. id: id,
  1242. },
  1243. res => {
  1244. if (res.code == "ok") {
  1245. this.$message({
  1246. message: '操作成功',
  1247. type: "success"
  1248. });
  1249. this.getReviewList()
  1250. } else {
  1251. this.$message({
  1252. message: res.msg,
  1253. type: "error"
  1254. });
  1255. }
  1256. },
  1257. error => {
  1258. this.$message({
  1259. message: error,
  1260. type: "error"
  1261. });
  1262. });
  1263. },
  1264. // 获取薪资上传记录
  1265. xzjl() {
  1266. this.http.post('/finance-import/list', {
  1267. companyId: this.user.companyId,
  1268. // pageIndex:1,
  1269. // pageSize: 9999
  1270. },
  1271. res => {
  1272. if (res.code == "ok") {
  1273. console.log('123',res.data)
  1274. this.xzList = res.data.passList
  1275. } else {
  1276. this.$message({
  1277. message: res.msg,
  1278. type: "error"
  1279. });
  1280. }
  1281. },
  1282. error => {
  1283. this.$message({
  1284. message: error,
  1285. type: "error"
  1286. });
  1287. });
  1288. },
  1289. //导入分摊比例
  1290. intoAmortizationRatio(){
  1291. this.intoAmortizationDialog = true;
  1292. },
  1293. batchImportData(item) {
  1294. //首先判断文件类型
  1295. let str = item.file.name.split(".");
  1296. let format = str[str.length - 1];
  1297. if (format != "xls" && format != "xlsx") {
  1298. this.$message({
  1299. message: "请选择.xls或.xlsx文件",
  1300. type: "error"
  1301. });
  1302. } else {
  1303. this.importingData = true;
  1304. let formData = new FormData();
  1305. formData.append("file", item.file);
  1306. formData.append("companyId", this.user.companyId);
  1307. this.http.uploadFile('/report/importData', formData,
  1308. res => {
  1309. this.$refs.upload.clearFiles();
  1310. this.importingData = false;
  1311. this.showImportResult = true;
  1312. if (res.code == "ok") {
  1313. //换成弹出框,以免有人等了半天回来啥也没看到
  1314. this.importResultMsg = "成功导入"+res.data+"条分摊比例数据。"+(res.msg?res.msg:"");;
  1315. this.getReportList();
  1316. this.importWXDialog = false;
  1317. } else {
  1318. this.importResultMsg = "导入失败:"+res.msg;
  1319. }
  1320. },
  1321. error => {
  1322. this.$refs.upload.clearFiles();
  1323. this.importingData = false;
  1324. this.$message({
  1325. message: error,
  1326. type: "error"
  1327. });
  1328. });
  1329. }
  1330. },
  1331. },
  1332. created() {
  1333. var d = new Date();
  1334. this.date = d.getFullYear() +'-'+ ((d.getMonth()+1) < 10? '0'+(d.getMonth()+1):d.getMonth()+1);
  1335. },
  1336. mounted() {
  1337. let height = window.innerHeight;
  1338. this.tableHeight = height - 245;
  1339. const that = this;
  1340. window.onresize = function temp() {
  1341. that.tableHeight = window.innerHeight - 245;
  1342. };
  1343. this.getCustomColumn();
  1344. this.getList();
  1345. // this.getProjects();
  1346. this.addreviewer();
  1347. this.arrter()
  1348. this.getMonths()
  1349. },
  1350. updated() {
  1351. this.$nextTick(() => {
  1352. this.$refs['table'].doLayout();
  1353. })
  1354. }
  1355. };
  1356. </script>
  1357. <style lang="scss" scoped>
  1358. .nameList {
  1359. height: 400px;
  1360. overflow: auto;
  1361. }
  1362. </style>