index.vue 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598
  1. <template>
  2. <div class="app-container barchart">
  3. <!-- 搜索栏 -->
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  5. <el-form-item label="课程内容" prop="plantName">
  6. <el-input
  7. v-model="queryParams.plantName"
  8. placeholder="请输入课程内容"
  9. clearable
  10. size="small"
  11. @keyup.enter.native="handleQuery"
  12. />
  13. </el-form-item>
  14. <el-form-item label="开始日期" prop="startDate">
  15. <el-date-picker clearable size="small" style="width: 200px"
  16. v-model="queryParams.startDate"
  17. type="date"
  18. value-format="yyyy-MM-dd"
  19. placeholder="选择开始日期">
  20. </el-date-picker>
  21. </el-form-item>
  22. <el-form-item label="结束日期" prop="endDate">
  23. <el-date-picker clearable size="small" style="width: 200px"
  24. v-model="queryParams.endDate"
  25. type="date"
  26. value-format="yyyy-MM-dd"
  27. placeholder="选择结束日期">
  28. </el-date-picker>
  29. </el-form-item>
  30. <el-form-item :label="$t('申请状态')" prop="approveStatus">
  31. <el-select v-model="queryParams.approveStatus" :placeholder="$t('请选择') + $t('申请状态')" clearable size="small">
  32. <el-option
  33. v-for="dict in approveStatusOptions"
  34. :key="dict.dictValue"
  35. :label="dict.dictLabel"
  36. :value="dict.dictValue"
  37. />
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  42. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  43. </el-form-item>
  44. </el-form>
  45. <!-- 顶部工具栏 -->
  46. <el-row :gutter="10" class="mb8">
  47. <el-col :span="1.5">
  48. <el-button
  49. type="primary"
  50. icon="el-icon-plus"
  51. size="mini"
  52. @click="handleAdd"
  53. v-hasPermi="['spec:plan:add']"
  54. >新增</el-button>
  55. </el-col>
  56. <!-- <el-col :span="1.5">
  57. <el-button
  58. type="success"
  59. icon="el-icon-edit"
  60. size="mini"
  61. :disabled="single"
  62. @click="handleUpdate"
  63. v-hasPermi="['spec:plan:edit']"
  64. >修改</el-button>
  65. </el-col>
  66. <el-col :span="1.5">
  67. <el-button
  68. type="danger"
  69. icon="el-icon-delete"
  70. size="mini"
  71. :disabled="multiple"
  72. @click="handleDelete"
  73. v-hasPermi="['spec:plan:remove']"
  74. >删除</el-button>
  75. </el-col> -->
  76. <el-col :span="1.5">
  77. <el-button
  78. type="info"
  79. icon="el-icon-upload2"
  80. size="mini"
  81. @click="handleImport"
  82. v-hasPermi="['spec:plan:edit']"
  83. >导入</el-button>
  84. </el-col>
  85. <el-col :span="1.5">
  86. <el-button
  87. type="warning"
  88. icon="el-icon-download"
  89. size="mini"
  90. @click="handleExport"
  91. v-hasPermi="['spec:plan:export']"
  92. >导出</el-button>
  93. </el-col>
  94. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  95. </el-row>
  96. <!-- 表格 -->
  97. <el-table v-loading="loading" ref="planTable" :data="planList" @selection-change="handleSelectionChange" :height="clientHeight" border :cell-style="tableCellStyle">
  98. <el-table-column type="selection" width="55" align="center" />
  99. <el-table-column label="员工" fixed="left" align="center" prop="staffName" :show-overflow-tooltip="true"/>
  100. <el-table-column label="课程内容" fixed="left" align="center" width="150" prop="plantName" :show-overflow-tooltip="true"/>
  101. <el-table-column label="开始日期" width="90" fixed="left" align="center" prop="startDate">
  102. <template slot-scope="scope">
  103. <span>{{ parseTime(scope.row.startDate, '{y}-{m}-{d}') }}</span>
  104. </template>
  105. </el-table-column>
  106. <el-table-column label="结束日期" width="90" fixed="left" align="center" prop="endDate">
  107. <template slot-scope="scope">
  108. <span>{{ parseTime(scope.row.endDate, '{y}-{m}-{d}') }}</span>
  109. </template>
  110. </el-table-column>
  111. <el-table-column label="实际完成日期" width="105" align="center" prop="dateOfCompletion">
  112. <template slot-scope="scope">
  113. <span>{{ parseTime(scope.row.dateOfCompletion, '{y}-{m}-{d}') }}</span>
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="具体内容" align="center" width="200" prop="classContent" :show-overflow-tooltip="true"/>
  117. <el-table-column label="学习状态" align="center" prop="studyState" :formatter="studyStateFormat"/>
  118. <el-table-column :label="$t('申请状态')" align="center" prop="approveStatus"
  119. :show-overflow-tooltip="true">
  120. <template slot-scope="scope">
  121. <el-tag
  122. :type="approveStatusType(scope.row.approveStatus)"
  123. disable-transitions>{{approveStatusFormat(scope.row)}}</el-tag>
  124. </template>
  125. </el-table-column>
  126. <el-table-column label="创建人" align="center" prop="createBy" :show-overflow-tooltip="true"/>
  127. <el-table-column label="创建时间" align="center" prop="createdate" width="130">
  128. <template slot-scope="scope">
  129. <span>{{ parseTime(scope.row.createdate, '{y}-{m}-{d} {h}:{i}') }}</span>
  130. </template>
  131. </el-table-column>
  132. <el-table-column label="修改人" align="center" prop="updateBy" :show-overflow-tooltip="true"/>
  133. <el-table-column label="修改时间" align="center" prop="updatedate" width="130">
  134. <template slot-scope="scope">
  135. <span>{{ parseTime(scope.row.updatedate, '{y}-{m}-{d} {h}:{i}') }}</span>
  136. </template>
  137. </el-table-column>
  138. <!-- 渲染时间(年|月) -->
  139. <el-table-column
  140. v-if="IsShowyear"
  141. v-for="(item, index) in showMonths"
  142. :label="item.year"
  143. prop="showMonths"
  144. align="center"
  145. :key="index"
  146. >
  147. <el-table-column
  148. v-for="(it, index1) in item.months"
  149. :label="it.str"
  150. prop="str"
  151. min-width="50"
  152. style="padding: 0; margin: 0;"
  153. align="center"
  154. :key="index1"
  155. >
  156. <template slot-scope="scope" class="progressCon">
  157. <div v-if="getCellDateWidth > 0">
  158. <div
  159. v-if="index === 0 && index1 === 0 && scope.$index % 2 === 0"
  160. class="progressUpon"
  161. :style="{width:optimizeCalcWidth(scope.row),left:optimizeCalcLeft(scope.row)}"
  162. ></div>
  163. <div
  164. v-else-if="index === 0 && index1 === 0 && scope.$index % 2 !== 0"
  165. class="progressDownon"
  166. :style="{width:optimizeCalcWidth(scope.row),left:optimizeCalcLeft(scope.row)}"
  167. ></div>
  168. </div>
  169. <div v-else>
  170. <div
  171. v-if="scope.$index % 2 === 0"
  172. :class="scope.row.beginTimeStamp <= it.endTimeStamp && scope.row.endTimeStamp >= it.beginTimeStamp ? 'progressUpon' : '' "
  173. :style="{width:scope.row.beginTimeStamp <= it.endTimeStamp && scope.row.endTimeStamp >= it.beginTimeStamp ? calcwidth(scope.row,it) : '0px',left:scope.row.beginTimeStamp <= it.endTimeStamp && scope.row.endTimeStamp >= it.beginTimeStamp ? calcLeft(scope.row,it) : '0px'}"
  174. ></div>
  175. <div v-else
  176. :class="scope.row.beginTimeStamp <= it.endTimeStamp && scope.row.endTimeStamp >= it.beginTimeStamp ? 'progressDownon' : '' "
  177. :style="{width:scope.row.beginTimeStamp <= it.endTimeStamp && scope.row.endTimeStamp >= it.beginTimeStamp ? calcwidth(scope.row,it) : '0px',left:scope.row.beginTimeStamp <= it.endTimeStamp && scope.row.endTimeStamp >= it.beginTimeStamp ? calcLeft(scope.row,it) : '0px'}"
  178. ></div>
  179. </div>
  180. </template>
  181. </el-table-column>
  182. </el-table-column>
  183. <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width" width="400">
  184. <template slot-scope="scope">
  185. <el-button
  186. size="mini"
  187. type="text"
  188. icon="el-icon-chat-dot-round"
  189. @click="handleFeedback(scope.row)"
  190. v-hasPermi="['spec:plan:edit']"
  191. >反馈</el-button>
  192. <el-button
  193. size="mini"
  194. type="text"
  195. icon="el-icon-document"
  196. @click="handleDocSuccessor(scope.row)"
  197. v-hasPermi="['spec:plan:edit']"
  198. >学员附件</el-button>
  199. <el-button
  200. size="mini"
  201. type="text"
  202. icon="el-icon-document"
  203. @click="handleDocMentor(scope.row)"
  204. v-hasPermi="['spec:plan:edit']"
  205. >学习资料</el-button>
  206. <el-button
  207. v-if="scope.row.editFlag != 0"
  208. size="mini"
  209. type="text"
  210. icon="el-icon-edit"
  211. @click="handleUpdate(scope.row)"
  212. v-hasPermi="['spec:plan:edit']"
  213. >修改</el-button>
  214. <el-button
  215. v-if="scope.row.editFlag != 0"
  216. size="mini"
  217. type="text"
  218. icon="el-icon-delete"
  219. @click="handleDelete(scope.row)"
  220. v-hasPermi="['spec:plan:remove']"
  221. >删除</el-button>
  222. </template>
  223. </el-table-column>
  224. </el-table>
  225. <!-- 分页 -->
  226. <pagination
  227. v-show="total>0"
  228. :total="total"
  229. :page.sync="queryParams.pageNum"
  230. :limit.sync="queryParams.pageSize"
  231. @pagination="getList"
  232. />
  233. <!-- 添加或修改培训计划对话框 -->
  234. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  235. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  236. <el-form-item label="员工" prop="staffId" >
  237. <el-select v-model="form.staffId" placeholder="请选择学员" disabled>
  238. <el-option
  239. v-for="successor in successorOptions"
  240. :key="successor.key"
  241. :label="successor.value"
  242. :value="successor.key"
  243. ></el-option>
  244. </el-select>
  245. </el-form-item>
  246. <el-form-item label="课程内容" prop="plantName">
  247. <el-input v-model="form.plantName" placeholder="请输入课程内容" />
  248. </el-form-item>
  249. <el-form-item label="开始日期" prop="startDate">
  250. <el-date-picker clearable size="small" style="width: 220px"
  251. v-model="form.startDate"
  252. type="date"
  253. value-format="yyyy-MM-dd"
  254. placeholder="选择开始日期"
  255. :picker-options="pickerOptionsStartDate">
  256. </el-date-picker>
  257. </el-form-item>
  258. <el-form-item label="结束日期" prop="endDate">
  259. <el-date-picker clearable size="small" style="width: 220px"
  260. v-model="form.endDate"
  261. type="date"
  262. value-format="yyyy-MM-dd"
  263. placeholder="选择结束日期"
  264. :picker-options="pickerOptionsEndDate">
  265. </el-date-picker>
  266. </el-form-item>
  267. <el-form-item label="具体内容">
  268. <el-input
  269. type="textarea"
  270. :rows="6"
  271. placeholder="请输入内容"
  272. v-model="form.classContent">
  273. </el-input>
  274. </el-form-item>
  275. </el-form>
  276. <div slot="footer" class="dialog-footer">
  277. <el-button type="primary" @click="submitForm">确 定</el-button>
  278. <el-button @click="cancel">取 消</el-button>
  279. </div>
  280. </el-dialog>
  281. <!-- 用户导入对话框 -->
  282. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  283. <el-upload
  284. ref="upload"
  285. :limit="1"
  286. accept=".xlsx, .xls"
  287. :headers="upload.headers"
  288. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  289. :disabled="upload.isUploading"
  290. :on-progress="handleFileUploadProgress"
  291. :on-success="handleFileSuccess"
  292. :auto-upload="false"
  293. drag
  294. >
  295. <i class="el-icon-upload"></i>
  296. <div class="el-upload__text">
  297. 将文件拖到此处,或
  298. <em>点击上传</em>
  299. </div>
  300. <div class="el-upload__tip" slot="tip">
  301. <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
  302. <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
  303. </div>
  304. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  305. </el-upload>
  306. <div slot="footer" class="dialog-footer">
  307. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  308. <el-button @click="upload.open = false">取 消</el-button>
  309. </div>
  310. </el-dialog>
  311. <!-- 学习资料对话框 -->
  312. <el-dialog v-dialogDrag :title="docMentor.title" :visible.sync="docMentor.open" width="700px" append-to-body>
  313. <el-upload
  314. ref="docMentor"
  315. :limit="50"
  316. :headers="docMentor.headers"
  317. :action="docMentor.url + '?pType=' + docMentor.pType + '&pId=' + docMentor.pId"
  318. :disabled="docMentor.isUploading"
  319. :on-progress="handleFileDocProgressMentor"
  320. :on-success="handleFileDocSuccessMentor"
  321. :auto-upload="true"
  322. drag
  323. >
  324. <i class="el-icon-upload"></i>
  325. <div class="el-upload__text">
  326. {{ $t('将文件拖到此处,或') }}
  327. <em>{{ $t('点击上传') }}</em>
  328. </div>
  329. </el-upload>
  330. <el-table :data="docMentor.commonfileList" border>
  331. <el-table-column :label="$t('文件名')" align="center" prop="fileName" :show-overflow-tooltip="true">
  332. <template slot-scope="scope">
  333. <a class="link-type" @click="handleDownload(scope.row)">
  334. <span>{{ scope.row.fileName }}</span>
  335. </a>
  336. </template>
  337. </el-table-column>
  338. <el-table-column :label="$t('大小(Kb)')" align="center" prop="fileSize" :show-overflow-tooltip="true" width="80" />
  339. <el-table-column :label="$t('上传人')" align="center" prop="creator" :show-overflow-tooltip="true" width="120"/>
  340. <el-table-column :label="$t('操作')" align="center" width="120" class-name="small-padding fixed-width">
  341. <template slot-scope="scope">
  342. <el-button
  343. v-if="scope.row.fileName.endsWith('pdf')"
  344. size="mini"
  345. type="text"
  346. icon="el-icon-view"
  347. @click="handleSee(scope.row)"
  348. >{{ $t('预览') }}</el-button>
  349. <el-button
  350. size="mini"
  351. type="text"
  352. icon="el-icon-download"
  353. @click="handleDownload(scope.row)"
  354. >{{ $t('下载') }}</el-button>
  355. <el-button
  356. size="mini"
  357. type="text"
  358. icon="el-icon-delete"
  359. @click="handleDeleteDoc(scope.row)"
  360. >{{ $t('删除') }}</el-button>
  361. </template>
  362. </el-table-column>
  363. </el-table>
  364. <el-dialog v-dialogDrag :title="pdf.title" :visible.sync="pdf.open" width="1300px" append-to-body>
  365. <div style="margin-top: -60px;float: right;margin-right: 40px;">
  366. <el-button size="mini" type="text" @click="openPdf">{{$t('新页面打开PDF')}}</el-button></div>
  367. <div style="margin-top: -30px">
  368. <iframe :src="pdf.pdfUrl" frameborder="0" width="100%" height="700px"></iframe>
  369. </div>
  370. </el-dialog>
  371. <div slot="footer" class="dialog-footer">
  372. <el-button @click="docMentor.open = false">{{ $t('返 回') }}</el-button>
  373. </div>
  374. </el-dialog>
  375. <!-- 学员附件对话框 -->
  376. <el-dialog v-dialogDrag :title="docSuccessor.title" :visible.sync="docSuccessor.open" width="700px" append-to-body>
  377. <el-table :data="docSuccessor.commonfileList" border>
  378. <el-table-column :label="$t('文件名')" align="center" prop="fileName" :show-overflow-tooltip="true">
  379. <template slot-scope="scope">
  380. <a class="link-type" @click="handleDownload(scope.row)">
  381. <span>{{ scope.row.fileName }}</span>
  382. </a>
  383. </template>
  384. </el-table-column>
  385. <el-table-column :label="$t('大小(Kb)')" align="center" prop="fileSize" :show-overflow-tooltip="true" width="80" />
  386. <el-table-column :label="$t('上传人')" align="center" prop="creator" :show-overflow-tooltip="true" width="120"/>
  387. <el-table-column :label="$t('操作')" align="center" width="120" class-name="small-padding fixed-width">
  388. <template slot-scope="scope">
  389. <el-button
  390. v-if="scope.row.fileName.endsWith('pdf')"
  391. size="mini"
  392. type="text"
  393. icon="el-icon-view"
  394. @click="handleSee(scope.row)"
  395. >{{ $t('预览') }}</el-button>
  396. <el-button
  397. size="mini"
  398. type="text"
  399. icon="el-icon-download"
  400. @click="handleDownload(scope.row)"
  401. >{{ $t('下载') }}</el-button>
  402. </template>
  403. </el-table-column>
  404. </el-table>
  405. <el-dialog v-dialogDrag :title="pdf.title" :visible.sync="pdf.open" width="1300px" append-to-body>
  406. <div style="margin-top: -60px;float: right;margin-right: 40px;">
  407. <el-button size="mini" type="text" @click="openPdf">{{$t('新页面打开PDF')}}</el-button></div>
  408. <div style="margin-top: -30px">
  409. <iframe :src="pdf.pdfUrl" frameborder="0" width="100%" height="700px"></iframe>
  410. </div>
  411. </el-dialog>
  412. <div slot="footer" class="dialog-footer">
  413. <el-button @click="docSuccessor.open = false">{{ $t('返 回') }}</el-button>
  414. </div>
  415. </el-dialog>
  416. <!-- 反馈对话框 -->
  417. <el-dialog v-dialogDrag :title="feedbackDialog.title" :visible.sync="feedbackDialog.open" width="800px" append-to-body>
  418. <div style="width:700px; margin:0px auto;">
  419. <h3 style="margin-bottom:20px;">学员心得</h3>
  420. <el-table :data="tableData" border style="width: 100%">
  421. <el-table-column prop="id" label="编号" width="50"></el-table-column>
  422. <el-table-column prop="question" label="问题" width="250"></el-table-column>
  423. <el-table-column prop="answer" label="答案"></el-table-column>
  424. </el-table>
  425. <el-table :data="docFeedback.commonfileList" border>
  426. <el-table-column :label="$t('文件名')" align="center" prop="fileName" :show-overflow-tooltip="true">
  427. <template slot-scope="scope">
  428. <a class="link-type" @click="handleDownload(scope.row)">
  429. <span>{{ scope.row.fileName }}</span>
  430. </a>
  431. </template>
  432. </el-table-column>
  433. <el-table-column :label="$t('大小(Kb)')" align="center" prop="fileSize" :show-overflow-tooltip="true" width="80" />
  434. <el-table-column :label="$t('上传人')" align="center" prop="creator" :show-overflow-tooltip="true" width="120"/>
  435. <el-table-column :label="$t('操作')" align="center" width="120" class-name="small-padding fixed-width">
  436. <template slot-scope="scope">
  437. <el-button
  438. v-if="scope.row.fileName.endsWith('pdf')"
  439. size="mini"
  440. type="text"
  441. icon="el-icon-view"
  442. @click="handleSee(scope.row)"
  443. >{{ $t('预览') }}</el-button>
  444. <el-button
  445. size="mini"
  446. type="text"
  447. icon="el-icon-download"
  448. @click="handleDownload(scope.row)"
  449. >{{ $t('下载') }}</el-button>
  450. </template>
  451. </el-table-column>
  452. </el-table>
  453. <el-form v-if="feedbackDialog.studyState == 2">
  454. <h3 style="margin-top:30px;margin-bottom:20px;">导师反馈</h3>
  455. <el-form-item>
  456. <editor v-model="feedbackParams.mentorFeedback" :min-height="192"/>
  457. </el-form-item>
  458. </el-form>
  459. <el-form v-if="mentorFeedback != null && feedbackDialog.studyState != 2">
  460. <h3 style="margin-top:30px;margin-bottom:20px;">导师反馈</h3>
  461. <el-form-item>
  462. <p v-html="mentorFeedback" style="border:1px solid #DFE6EC; overflow:scroll; height:200px;" />
  463. </el-form-item>
  464. </el-form>
  465. <div style="text-align:center;">
  466. <el-button
  467. @click="handleApprove()"
  468. type="success"
  469. size="medium"
  470. style="margin-right:25px;"
  471. v-if="feedbackDialog.studyState == 2"
  472. >
  473. {{ $t('通 过') }}
  474. </el-button>
  475. <el-button
  476. @click="handleReject()"
  477. type="danger"
  478. size="medium"
  479. v-if="feedbackDialog.studyState == 2"
  480. >
  481. {{ $t('驳 回') }}
  482. </el-button>
  483. </div>
  484. </div>
  485. </el-dialog>
  486. <plan-approve v-if="planApproveVisible" ref="planApprove" @refreshDataList="getList"></plan-approve>
  487. </div>
  488. </template>
  489. <script>
  490. import { getFeedbackByPlanId } from "@/api/training/spec/feedback";
  491. import { addFeedback, updateFeedback } from "@/api/training/spec/feedback";
  492. import { getAnswer } from "@/api/training/spec/answer";
  493. import { getPlan, listPlanByYearId, delPlan, addPlan, updatePlan, updatePlan2, exportPlan, importTemplate } from "@/api/training/spec/plan";
  494. import { allFileList, delCommonfile } from "@/api/common/commonfile";
  495. import { treeselect } from "@/api/system/dept";
  496. import { getToken } from "@/utils/auth";
  497. import PlanApprove from "./plan-approve"
  498. import Treeselect from "@riophae/vue-treeselect";
  499. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  500. import {getYearplan} from "@/api/training/spec/yearplan";
  501. import Editor from '@/components/Editor';
  502. export default {
  503. name: "Plan",
  504. components: { Treeselect, PlanApprove, Editor },
  505. data() {
  506. return {
  507. // 报告附件参数
  508. docFeedback: { // 反馈附件
  509. file: "",
  510. // 是否显示弹出层(报告附件)
  511. open: false,
  512. // 弹出层标题(报告附件)
  513. title: "",
  514. // 是否禁用上传
  515. isUploading: false,
  516. // 是否更新已经存在的用户数据
  517. updateSupport: 0,
  518. // 报告附件上传位置编号
  519. ids: 0,
  520. // 设置上传的请求头部
  521. headers: { Authorization: "Bearer " + getToken() },
  522. // 上传的地址
  523. url: process.env.VUE_APP_BASE_API + "/common/commonfile/uploadFile",
  524. commonfileList: null,
  525. queryParams: {
  526. pId: null,
  527. pType: 'docFeedback'
  528. },
  529. pType: 'docFeedback',
  530. pId: null
  531. },
  532. docMentor: { // 学习资料
  533. file: "",
  534. // 是否显示弹出层(报告附件)
  535. open: false,
  536. // 弹出层标题(报告附件)
  537. title: "",
  538. // 是否禁用上传
  539. isUploading: false,
  540. // 是否更新已经存在的用户数据
  541. updateSupport: 0,
  542. // 报告附件上传位置编号
  543. ids: 0,
  544. // 设置上传的请求头部
  545. headers: { Authorization: "Bearer " + getToken() },
  546. // 上传的地址
  547. url: process.env.VUE_APP_BASE_API + "/common/commonfile/uploadFile",
  548. commonfileList: null,
  549. queryParams: {
  550. pId: null,
  551. pType: 'docMentor'
  552. },
  553. pType: 'docMentor',
  554. pId: null
  555. },
  556. docSuccessor: { // 学员附件
  557. file: "",
  558. // 是否显示弹出层(报告附件)
  559. open: false,
  560. // 弹出层标题(报告附件)
  561. title: "",
  562. // 是否禁用上传
  563. isUploading: false,
  564. // 是否更新已经存在的用户数据
  565. updateSupport: 0,
  566. // 报告附件上传位置编号
  567. ids: 0,
  568. // 设置上传的请求头部
  569. headers: { Authorization: "Bearer " + getToken() },
  570. // 上传的地址
  571. url: process.env.VUE_APP_BASE_API + "/common/commonfile/uploadFile",
  572. commonfileList: null,
  573. queryParams: {
  574. pId: null,
  575. pType: 'docSuccessor'
  576. },
  577. pType: 'docSuccessor',
  578. pId: null
  579. },
  580. // 导师反馈内容
  581. mentorFeedback: null,
  582. // 开始日期不能跨年
  583. pickerOptionsStartDate: {
  584. disabledDate(time) {
  585. return time.getYear() != new Date().getYear();
  586. }
  587. },
  588. // 结束日期不能跨年
  589. pickerOptionsEndDate: {
  590. disabledDate(time) {
  591. return time.getYear() != new Date().getYear();
  592. }
  593. },
  594. // 反馈参数
  595. feedbackParams: {
  596. id: null,
  597. mentorFeedback: null
  598. },
  599. showMonths:[],
  600. minDay:"", // 最小日期
  601. maxDay:"", // 最大日期
  602. IsShowyear:true, // 显示年|月 、 月|日
  603. // 查看培养详情参数
  604. detail: {
  605. // 是否显示弹出层(报告附件)
  606. open: false,
  607. // 弹出层标题(报告附件)
  608. title: ""
  609. },
  610. // 反馈对话框参数
  611. feedbackDialog: {
  612. id: 0,
  613. // 是否显示弹出层(报告附件)
  614. open: false,
  615. // 弹出层标题(报告附件)
  616. title: "",
  617. // 学习状态
  618. studyState: null,
  619. // 计划id
  620. planId: null,
  621. },
  622. // 遮罩层
  623. loading: true,
  624. planApproveVisible: false,
  625. // 选中数组
  626. ids: [],
  627. dataListSelections: [],
  628. // 非单个禁用
  629. single: true,
  630. // 非多个禁用
  631. multiple: true,
  632. // 显示搜索条件
  633. showSearch: false,
  634. // 总条数
  635. total: 0,
  636. // 培养计划表格数据
  637. planList: [],
  638. // 弹出层标题
  639. title: "",
  640. // 操作
  641. operation: "",
  642. // 部门树选项
  643. deptOptions: undefined,
  644. clientHeight:300,
  645. // 是否显示弹出层
  646. open: false,
  647. // 学习状态字典
  648. studyStateOptions: [],
  649. approveStatusOptions: [],
  650. // 学员列表
  651. successorOptions: [],
  652. // 包含导师ID的查询对象
  653. queryObject: {
  654. mentorStaffId: ""
  655. },
  656. // 用户导入参数
  657. upload: {
  658. // 是否显示弹出层(用户导入)
  659. open: false,
  660. // 弹出层标题(用户导入)
  661. title: "",
  662. // 是否禁用上传
  663. isUploading: false,
  664. // 是否更新已经存在的用户数据
  665. updateSupport: 0,
  666. // 设置上传的请求头部
  667. headers: { Authorization: "Bearer " + getToken() },
  668. // 上传的地址
  669. url: process.env.VUE_APP_BASE_API + "/spec/plan/importData"
  670. },
  671. // 查询参数
  672. queryParams: {
  673. pageNum: 1,
  674. pageSize: 20,
  675. staffId: null,
  676. plantName: null,
  677. startDate: null,
  678. endDate: null,
  679. classHour: null,
  680. studyState: null,
  681. yearPlanId: null
  682. },
  683. // 表单参数
  684. form: {},
  685. // 表单校验
  686. rules: {
  687. },
  688. // pdf文件参数
  689. pdf : {
  690. title: '',
  691. pdfUrl: '',
  692. numPages: null,
  693. open: false,
  694. pageNum: 1,
  695. pageTotalNum: 1,
  696. loadedRatio: 0,
  697. },
  698. // 表格参数
  699. tableData: [],
  700. };
  701. },
  702. watch: {
  703. // 根据名称筛选部门树
  704. deptName(val) {
  705. this.$refs.tree.filter(val);
  706. }
  707. },
  708. computed:{
  709. // 获取最小日期-月开始时间戳
  710. minDayTimeStamp() {
  711. if(this.IsShowyear){
  712. return this.showMonths[0].months[0].beginTimeStamp
  713. }else{
  714. return this.showMonths[0].days[0].daysArr[0].timestamp
  715. }
  716. },
  717. // 获取最大日期时间戳
  718. maxDayTimeStamp() {
  719. let Length = this.showMonths.length // 年有多少个
  720. // 如果显示年|月 与 月|日 是不同的
  721. if(this.IsShowyear){
  722. let monthsLength = this.showMonths[Length - 1].months.length //月有多少个
  723. return this.showMonths[Length - 1].months[monthsLength - 1].endTimeStamp
  724. }else{
  725. let daysLength = this.showMonths[Length - 1].days.length
  726. let daysarrLength = this.showMonths[Length - 1].days[daysLength - 1].daysArr.length //天有多少个
  727. return this.showMonths[Length - 1].days[daysLength - 1].daysArr[daysarrLength - 1].timestamp + 86400000 //+86400000 是因为时间戳都是0点这样+1天的时间戳,就表示最晚一天的最后的时间
  728. }
  729. },
  730. // 最大日期与最小日期的时间戳差
  731. maxAndminDayTimeStamp() {
  732. return this.maxDayTimeStamp - this.minDayTimeStamp
  733. },
  734. // 获取日期单元格宽度 => 如果返回0则只用之前第一版的计算方法
  735. getCellDateWidth() {
  736. let num = 0 // 获取日期单元格数量
  737. if(this.IsShowyear){
  738. // 月数量
  739. for(let i = 0;i < this.showMonths.length;i++){
  740. num += this.showMonths[i].months.length
  741. }
  742. }else{
  743. // 天数量
  744. for(let i = 0;i < this.showMonths.length;i++){
  745. for(let j = 0;j < this.showMonths[i].days.length;j++){
  746. num += this.showMonths[i].days[j].daysArr.length
  747. }
  748. }
  749. }
  750. // 每个单元格最小30宽度
  751. let MaxWidth = window.screen.width
  752. let CellNum = MaxWidth / 30 > 0 ? MaxWidth / 30 : 0
  753. if(num >= CellNum){ // 页面宽 / 单元格最小宽度 = 最多放下的值
  754. return num * 30
  755. }else{
  756. // 单元格的值,就不能是最小值30了
  757. // 需要获取dom的宽度,在进行计算,但是dom还未渲染完成,因此这里就不考虑了,直接只用第一版的方法动态计算
  758. // TODO
  759. return 0
  760. }
  761. }
  762. },
  763. created() {
  764. //设置表格高度对应屏幕高度
  765. this.$nextTick(() => {
  766. this.clientHeight = document.body.clientHeight -250
  767. })
  768. const yearId = this.$route.params && this.$route.params.yearId;
  769. // 设置查询参数年度计划编号
  770. this.queryParams.yearPlanId = yearId;
  771. this.getList();
  772. this.getTreeselect();
  773. this.getDicts("st_study_state").then(response => {
  774. this.studyStateOptions = response.data;
  775. });
  776. this.getDicts("spec_training_approve_status").then(response => {
  777. this.approveStatusOptions = response.data;
  778. });
  779. },
  780. methods: {
  781. /** 单元格样式 */
  782. tableCellStyle (row, column, rowIndex, columnIndex) {
  783. // 超时学习突出显示
  784. if (row.column.label === "实际完成日期" && row.row.dateOfCompletion > row.row.endDate) {
  785. return "background: #FFEEEE"
  786. }
  787. // 修改过的计划突出显示
  788. if (row.column.label === "修改人" && row.row.updateBy!=null) {
  789. return "background: #FFFFDB"
  790. }
  791. if (row.column.label === "修改时间" && row.row.updatedate!=null) {
  792. return "background: #FFFFDB"
  793. }
  794. },
  795. /** 通过处理 */
  796. handleApprove() {
  797. this.feedbackParams.planId = this.feedbackDialog.planId;
  798. // 导师反馈内容,有则修改,无则新增
  799. if (this.mentorFeedback == null) {
  800. addFeedback(this.feedbackParams).then(response => {
  801. // 发邮件通知学员
  802. this.feedbackDialog.open = false;
  803. // 修改学习状态为1已完成
  804. let plan = {};
  805. plan.id = this.feedbackDialog.planId;
  806. plan.studyState = 1;
  807. plan.dateOfCompletion = new Date();
  808. updatePlan2(plan).then(response => {
  809. this.feedbackDialog.open = false;
  810. this.msgSuccess("已通过");
  811. this.getList();
  812. });
  813. });
  814. } else {
  815. updateFeedback(this.feedbackParams).then(response => {
  816. // 发邮件通知学员
  817. this.feedbackDialog.open = false;
  818. // 修改学习状态为1已完成
  819. let plan = {};
  820. // 获取计划id(修改条件)
  821. plan.id = this.feedbackDialog.planId;
  822. plan.studyState = 1;
  823. plan.dateOfCompletion = new Date();
  824. updatePlan2(plan).then(response => {
  825. this.feedbackDialog.open = false;
  826. this.msgSuccess("已通过");
  827. this.getList();
  828. });
  829. });
  830. }
  831. },
  832. /** 驳回处理 */
  833. handleReject() {
  834. this.feedbackParams.planId = this.feedbackDialog.planId;
  835. // 导师反馈内容:有则修改,无则新增
  836. if (this.mentorFeedback == null) {
  837. addFeedback(this.feedbackParams).then(response => {
  838. // 发邮件通知学员
  839. this.feedbackDialog.open = false;
  840. // 修改学习状态为3导师已反馈
  841. let plan = {};
  842. // 获取计划id(修改条件)
  843. plan.id = this.feedbackDialog.planId;
  844. plan.studyState = 3;
  845. updatePlan2(plan).then(response => {
  846. this.feedbackDialog.open = false;
  847. this.msgSuccess("已驳回");
  848. this.getList();
  849. });
  850. });
  851. } else {
  852. updateFeedback(this.feedbackParams).then(response => {
  853. // 发邮件通知学员
  854. this.feedbackDialog.open = false;
  855. // 修改学习状态为3导师已反馈
  856. let plan = {};
  857. plan.id = this.feedbackDialog.planId;
  858. plan.studyState = 3;
  859. plan.dateOfCompletion = new Date();
  860. updatePlan2(plan).then(response => {
  861. this.feedbackDialog.open = false;
  862. this.msgSuccess("已驳回");
  863. this.getList();
  864. });
  865. });
  866. }
  867. },
  868. /** 反馈处理 */
  869. handleFeedback(row) {
  870. // 加载反馈附件
  871. this.docFeedback.id = row.id;
  872. this.docFeedback.queryParams.pId = row.id
  873. this.docFeedback.pId = row.id
  874. this.getFileListFeedback()
  875. this.$nextTick(() => {
  876. this.$refs.docFeedback.clearFiles()
  877. })
  878. // 清空导师反馈内容
  879. this.feedbackParams.mentorFeedback = null;
  880. // 清空表格数据
  881. this.tableData = [];
  882. let feedback1 = {};
  883. feedback1.planId = row.id;
  884. feedback1.questionId = 1;
  885. let feedback2 = {};
  886. feedback2.planId = row.id;
  887. feedback2.questionId = 2;
  888. let feedback3 = {};
  889. feedback3.planId = row.id;
  890. feedback3.questionId = 3;
  891. let answerObj1 = {};
  892. let answerObj2 = {};
  893. let answerObj3 = {};
  894. // 获取问题和答案
  895. getAnswer(feedback1).then(response => {
  896. let data = response.data;
  897. if (data != null) {
  898. answerObj1 = { id: 1, question: data.question, answer: data.answer};
  899. }
  900. return getAnswer(feedback2);
  901. }).then(response => {
  902. let data = response.data;
  903. if (data != null) {
  904. answerObj2 = { id: 2, question: data.question, answer: data.answer};
  905. }
  906. return getAnswer(feedback3);
  907. }).then(response => {
  908. let data = response.data;
  909. if (data != null) {
  910. answerObj3 = { id: 3, question: data.question, answer: data.answer};
  911. this.tableData.push(answerObj1);
  912. this.tableData.push(answerObj2);
  913. this.tableData.push(answerObj3);
  914. }
  915. // 获取导师反馈内容
  916. return getFeedbackByPlanId(row.id);
  917. }).then(response => {
  918. if (response.data != null) {
  919. let data = response.data;
  920. this.mentorFeedback = data.mentorFeedback;
  921. this.feedbackParams.id = data.id;
  922. }
  923. this.feedbackDialog.title = row.staffName + row.plantName + "学习情况反馈";
  924. this.feedbackDialog.planId = row.id;
  925. this.feedbackDialog.studyState = row.studyState;
  926. this.feedbackDialog.open = true;
  927. });
  928. },
  929. /** 文件下载处理 */
  930. handleDownload(row) {
  931. var name = row.fileName;
  932. var url = row.fileUrl;
  933. var suffix = url.substring(url.lastIndexOf("."), url.length);
  934. const a = document.createElement('a')
  935. a.setAttribute('download', name)
  936. a.setAttribute('target', '_blank')
  937. a.setAttribute('href', process.env.VUE_APP_BASE_API + url)
  938. a.click()
  939. },
  940. openPdf(){
  941. window.open(this.pdf.pdfUrl);//path是文件的全路径地址
  942. },
  943. handleSee (row){
  944. this.pdf.open =true
  945. this.pdf.title = row.fileName
  946. this.pdf.pdfUrl = process.env.VUE_APP_BASE_API +'/pdf/web/viewer.html?file=' + process.env.VUE_APP_BASE_API + row.fileUrl
  947. },
  948. /** 报告附件按钮操作 */
  949. handleDocMentor(row) {
  950. this.docMentor.id = row.id;
  951. this.docMentor.title = row.plantName + this.$t('学习资料');
  952. this.docMentor.open = true;
  953. this.docMentor.queryParams.pId = row.id
  954. this.docMentor.pId = row.id
  955. this.getFileListMentor()
  956. this.$nextTick(() => {
  957. this.$refs.docMentor.clearFiles()
  958. })
  959. },
  960. handleDocSuccessor(row) {
  961. this.docSuccessor.id = row.id;
  962. this.docSuccessor.title = row.plantName + this.$t('学员附件');
  963. this.docSuccessor.open = true;
  964. this.docSuccessor.queryParams.pId = row.id
  965. this.docSuccessor.pId = row.id
  966. this.getFileListSuccessor()
  967. this.$nextTick(() => {
  968. this.$refs.docSuccessor.clearFiles()
  969. })
  970. },
  971. getFileListMentor() {
  972. allFileList(this.docMentor.queryParams).then(response => {
  973. this.docMentor.commonfileList = response;
  974. });
  975. },
  976. getFileListSuccessor() {
  977. allFileList(this.docSuccessor.queryParams).then(response => {
  978. this.docSuccessor.commonfileList = response;
  979. });
  980. },
  981. getFileListFeedback() {
  982. allFileList(this.docFeedback.queryParams).then(response => {
  983. this.docFeedback.commonfileList = response;
  984. });
  985. },
  986. /** 附件上传中处理 */
  987. handleFileDocProgressFeedback(event, file, fileList) {
  988. this.docFeedback.file = file;
  989. this.docFeedback.isUploading = true;
  990. },
  991. handleFileDocProgressMentor(event, file, fileList) {
  992. this.docMentor.file = file;
  993. this.docMentor.isUploading = true;
  994. },
  995. handleFileDocProgressSuccessor(event, file, fileList) {
  996. this.docSuccessor.file = file;
  997. this.docSuccessor.isUploading = true;
  998. },
  999. /** 附件上传成功处理 */
  1000. handleFileDocSuccessFeedback(response, file, fileList) {
  1001. this.docMentorFeedback.isUploading = false;
  1002. this.$alert(response.msg, this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  1003. this.getFileListFeedback()
  1004. },
  1005. handleFileDocSuccessMentor(response, file, fileList) {
  1006. this.docMentor.isUploading = false;
  1007. this.$alert(response.msg, this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  1008. this.getFileListMentor()
  1009. },
  1010. handleFileDocSuccessSuccessor(response, file, fileList) {
  1011. this.docSuccessor.isUploading = false;
  1012. this.$alert(response.msg, this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  1013. this.getFileListSuccessor()
  1014. },
  1015. /** 删除按钮操作 */
  1016. handleDeleteDoc(row) {
  1017. const ids = row.id || this.ids;
  1018. this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
  1019. confirmButtonText: this.$t('确定'),
  1020. cancelButtonText: this.$t('取消'),
  1021. type: "warning"
  1022. }).then(function() {
  1023. return delCommonfile(ids);
  1024. }).then(() => {
  1025. this.getFileList()
  1026. this.msgSuccess(this.$t('删除成功'));
  1027. })
  1028. },
  1029. /** 查询培训计划列表 */
  1030. getList() {
  1031. this.loading = true;
  1032. listPlanByYearId(this.queryParams).then(response => {
  1033. this.planList = response.rows;
  1034. this.total = response.total;
  1035. this.setrowspans() // 设置合并
  1036. this.getChartTitle() // 渲染的信息
  1037. this.$nextTick(() => {
  1038. this.$refs.planTable.doLayout(); // 解决表格错位
  1039. });
  1040. this.loading = false;
  1041. });
  1042. },
  1043. /** 查询部门下拉树结构 */
  1044. getTreeselect() {
  1045. treeselect().then(response => {
  1046. this.deptOptions = response.data;
  1047. });
  1048. },
  1049. /** 学习状态字典翻译 */
  1050. studyStateFormat(row, column) {
  1051. return this.selectDictLabel(this.studyStateOptions, row.studyState);
  1052. },
  1053. // 申请状态字典翻译
  1054. approveStatusFormat(row, column) {
  1055. return this.selectDictLabel(this.approveStatusOptions, row.approveStatus);
  1056. },
  1057. approveStatusType (type) {
  1058. if (type == 0) {
  1059. return 'danger'
  1060. }else if (type == 1) {
  1061. return 'success'
  1062. }else if (type == 2) {
  1063. return 'danger'
  1064. }else {
  1065. return 'info'
  1066. }
  1067. },
  1068. /** 取消按钮 */
  1069. cancel() {
  1070. this.open = false;
  1071. this.reset();
  1072. },
  1073. /** 表单重置 */
  1074. reset() {
  1075. this.form = {
  1076. id: null,
  1077. staffId: null,
  1078. plantName: null,
  1079. delFlag: null,
  1080. createrCode: null,
  1081. createdate: null,
  1082. updaterCode: null,
  1083. updatedate: null,
  1084. deptId: null,
  1085. startDate: null,
  1086. endDate: null,
  1087. classHour: null,
  1088. classContent: null,
  1089. studyState: null
  1090. };
  1091. this.resetForm("form");
  1092. },
  1093. /** 搜索按钮操作 */
  1094. handleQuery() {
  1095. this.queryParams.pageNum = 1;
  1096. this.getList();
  1097. },
  1098. /** 重置按钮操作 */
  1099. resetQuery() {
  1100. this.resetForm("queryForm");
  1101. this.handleQuery();
  1102. },
  1103. /** 多选框选中数据 */
  1104. handleSelectionChange(selection) {
  1105. this.ids = selection.map(item => item.id)
  1106. this.single = selection.length!==1
  1107. this.multiple = !selection.length
  1108. this.dataListSelections = selection
  1109. },
  1110. /** 新增按钮操作 */
  1111. handleAdd() {
  1112. this.reset();
  1113. getYearplan(this.queryParams.yearPlanId).then(response => {
  1114. this.form.staffId = response.data.staffId.toString();
  1115. this.open = true;
  1116. this.title = "添加培养计划";
  1117. this.operation = "modify";
  1118. });
  1119. this.open = true;
  1120. this.title = "添加培养计划";
  1121. this.operation = "add";
  1122. },
  1123. /** 修改按钮操作 */
  1124. handleUpdate(row) {
  1125. this.reset();
  1126. const id = row.id || this.ids
  1127. getPlan(id).then(response => {
  1128. this.form = response.data;
  1129. this.open = true;
  1130. this.title = "修改培养计划";
  1131. this.operation = "modify";
  1132. });
  1133. },
  1134. /** 提交按钮 */
  1135. submitForm() {
  1136. this.$refs["form"].validate(valid => {
  1137. if (valid) {
  1138. if (this.form.id != null) {
  1139. updatePlan(this.form).then(response => {
  1140. this.msgSuccess("修改成功");
  1141. this.open = false;
  1142. this.getList();
  1143. });
  1144. } else {
  1145. // 设置表单参数年度计划编号
  1146. this.form.yearPlanId = this.queryParams.yearPlanId;
  1147. addPlan(this.form).then(response => {
  1148. this.msgSuccess("新增成功");
  1149. this.open = false;
  1150. this.getList();
  1151. });
  1152. }
  1153. }
  1154. });
  1155. },
  1156. /** 删除按钮操作 */
  1157. handleDelete(row) {
  1158. const ids = row.id || this.ids;
  1159. this.$confirm('是否确认删除?', "警告", {
  1160. confirmButtonText: "确定",
  1161. cancelButtonText: "取消",
  1162. type: "warning"
  1163. }).then(function() {
  1164. return delPlan(ids);
  1165. }).then(() => {
  1166. this.getList();
  1167. this.msgSuccess("删除成功");
  1168. })
  1169. },
  1170. /** 导出按钮操作 */
  1171. handleExport() {
  1172. const queryParams = this.queryParams;
  1173. this.$confirm('是否确认导出所有培养计划数据项?', "警告", {
  1174. confirmButtonText: "确定",
  1175. cancelButtonText: "取消",
  1176. type: "warning"
  1177. }).then(function() {
  1178. return exportPlan(queryParams);
  1179. }).then(response => {
  1180. this.download(response.msg);
  1181. })
  1182. },
  1183. /** 导入按钮操作 */
  1184. handleImport() {
  1185. this.upload.title = "用户导入";
  1186. this.upload.open = true;
  1187. },
  1188. /** 下载模板操作 */
  1189. importTemplate() {
  1190. importTemplate().then(response => {
  1191. this.download(response.msg);
  1192. });
  1193. },
  1194. /** 文件上传中处理 */
  1195. handleFileUploadProgress(event, file, fileList) {
  1196. this.upload.isUploading = true;
  1197. },
  1198. /** 文件上传成功处理 */
  1199. handleFileSuccess(response, file, fileList) {
  1200. this.upload.open = false;
  1201. this.upload.isUploading = false;
  1202. this.$refs.upload.clearFiles();
  1203. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  1204. this.getList();
  1205. },
  1206. /** 提交上传文件 */
  1207. submitFileForm() {
  1208. this.$refs.upload.submit();
  1209. },
  1210. addAprrove (row, type) {
  1211. var rows = row ? [row] : this.dataListSelections.map(item => {
  1212. return item
  1213. })
  1214. this.planApproveVisible = true
  1215. console.log(rows)
  1216. console.log(type)
  1217. this.$nextTick(() => {
  1218. this.$refs.planApprove.init(rows, type)
  1219. })
  1220. },
  1221. optimizeCalcWidth(val) {
  1222. let SumNum = this.maxAndminDayTimeStamp
  1223. let diffNum = this.IsShowyear ? val.endTimeStamp - val.beginTimeStamp : val.endTimeStamp + 84600000 - val.beginTimeStamp // 结束日期 - 开始日期
  1224. let rate = Math.round(diffNum / SumNum * 10000) / 100.00 //得到百分比
  1225. let widthPx = this.getCellDateWidth * rate / 100.00
  1226. return widthPx + 'px'
  1227. },
  1228. optimizeCalcLeft(val) {
  1229. let SumNum = this.maxAndminDayTimeStamp
  1230. let diffNum = val.beginTimeStamp - this.minDayTimeStamp // 开始日期 - 整个月开始日期
  1231. let rate = Math.round(diffNum / SumNum * 10000) / 100.00 //得到百分比
  1232. let leftPx = this.getCellDateWidth * rate / 100.00
  1233. return leftPx + 'px'
  1234. },
  1235. // 计算图表的Left
  1236. calcLeft(val,date) {
  1237. // 如果本月的最大时间戳都没有结束时间长,那么就可判断
  1238. if(val.endTimeStamp > date.endTimeStamp){
  1239. // 如果本月开始日期小于开始日期
  1240. if(val.beginTimeStamp > date.beginTimeStamp){
  1241. // 进行判断
  1242. let diffNum = date.endTimeStamp - val.beginTimeStamp
  1243. let SumNum = date.endTimeStamp - date.beginTimeStamp
  1244. let rate = 100 - Math.round(diffNum / SumNum * 10000) / 100.00
  1245. // 位置判断
  1246. return rate+"%"
  1247. }
  1248. }else if(val.endTimeStamp > date.beginTimeStamp && val.endTimeStamp < date.endTimeStamp){
  1249. // 进行判断
  1250. if(val.beginTimeStamp > date.beginTimeStamp){
  1251. // 都在一个单元格中
  1252. let diffNum = val.beginTimeStamp - date.beginTimeStamp
  1253. let SumNum = date.endTimeStamp - date.beginTimeStamp
  1254. let rate = Math.round(diffNum / SumNum * 10000) / 100.00
  1255. // 位置判断
  1256. return rate+"%"
  1257. }
  1258. }
  1259. return '0px'
  1260. },
  1261. // 计算图表的Width
  1262. calcwidth(val,date) {
  1263. if(this.IsShowyear){
  1264. // 如果是 年|月
  1265. // 1. 如果本月的最大时间戳都没有结束时间长,那么就可设置100%
  1266. // 2. 如果本月的最小时间戳比结束时间长,那么设置0
  1267. // 3. 如果本月的最小时间戳没有结束时间长,那么进行判断
  1268. if(val.endTimeStamp > date.endTimeStamp){
  1269. // 如果本月开始日期小于开始日期
  1270. if(val.beginTimeStamp > date.beginTimeStamp){
  1271. // 进行判断
  1272. let diffNum = date.endTimeStamp - val.beginTimeStamp
  1273. let SumNum = date.endTimeStamp - date.beginTimeStamp
  1274. let rate = Math.round(diffNum / SumNum * 10000) / 100.00
  1275. return 'calc('+ rate +'% + 2px)' // 结束时间超过本月最大时间戳直接+2px
  1276. }
  1277. return 'calc(100% + 2px)'
  1278. }else if(val.endTimeStamp < date.beginTimeStamp){
  1279. return '0px'
  1280. }else if(val.endTimeStamp > date.beginTimeStamp && val.endTimeStamp <= date.endTimeStamp){
  1281. // 进行判断
  1282. if(val.beginTimeStamp > date.beginTimeStamp){
  1283. // 都在一个单元格中
  1284. let SumNum = date.endTimeStamp - date.beginTimeStamp // 全月多少数
  1285. let diffNum = val.endTimeStamp - val.beginTimeStamp // 过程多少数
  1286. diffNum = diffNum === 0 ? 86400000 : diffNum
  1287. let rate = Math.round(diffNum / SumNum * 10000) / 100.00
  1288. return 'calc('+ rate +'%)'
  1289. }else{
  1290. // 不在一个单元格中,则不需要判断任何信息
  1291. let diffNum = val.endTimeStamp - date.beginTimeStamp
  1292. let SumNum = date.endTimeStamp - date.beginTimeStamp
  1293. let rate = Math.round(diffNum / SumNum * 10000) / 100.00
  1294. return 'calc('+ rate +'%)'
  1295. }
  1296. }
  1297. }
  1298. return '0px'
  1299. },
  1300. //获得数据相同的行数(网络复制)
  1301. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  1302. if (columnIndex === 0) {
  1303. return {
  1304. rowspan: row.rowspan,
  1305. colspan: 1
  1306. };
  1307. }
  1308. },
  1309. // 根据id去分组(网络复制)
  1310. setrowspans() {
  1311. // 先给所有的数据都加一个v.rowspan = 1
  1312. this.planList.forEach(v => {
  1313. v.rowspan = 1;
  1314. });
  1315. // 双层循环
  1316. for (let i = 0; i < this.planList.length; i++) {
  1317. // 内层循环,上面已经给所有的行都加了v.rowspan = 1
  1318. // 这里进行判断
  1319. // 如果当前行的id和下一行的id相等
  1320. // 就把当前v.rowspan + 1
  1321. // 下一行的v.rowspan - 1
  1322. for (let j = i + 1; j < this.planList.length; j++) {
  1323. //此处可根据相同字段进行合并,此处是根据的id
  1324. if (this.planList[i].id === this.planList[j].id) {
  1325. this.planList[i].rowspan++;
  1326. this.planList[j].rowspan--;
  1327. }
  1328. }
  1329. // 这里跳过已经重复的数据
  1330. i = i + this.planList[i].rowspan - 1;
  1331. }
  1332. },
  1333. // 渲染表格头,首先是年月,如2018年11月
  1334. getChartTitle(startDate, endDate){
  1335. var chartTable = this.planList;
  1336. // 准备日期,为了防止多次赋值属性,导致计算属性重新计算,决定只赋值一次
  1337. let maxDayParams = "",minDayParams = ""
  1338. for(var i = 0; i < chartTable.length; i++){
  1339. var StartDate = chartTable[i].startDate;
  1340. var EndDate = chartTable[i].endDate;
  1341. var mainObj = chartTable[i];
  1342. // 计划日期
  1343. maxDayParams === "" ? maxDayParams = EndDate : ''
  1344. minDayParams === "" ? minDayParams = StartDate : ""
  1345. maxDayParams = this.compareDate(EndDate,maxDayParams,true)
  1346. minDayParams = this.compareDate(StartDate,minDayParams,false)
  1347. var days = this.GetNumberOfDays(StartDate,EndDate) // 计算工期
  1348. this.planList[i].days = days + 1 // 加一是因为没算结算当天
  1349. // 记录时间戳
  1350. this.planList[i].beginTimeStamp = this.getTimeStamp(StartDate)
  1351. this.planList[i].endTimeStamp = this.getTimeStamp(EndDate)
  1352. }
  1353. this.minDay = minDayParams
  1354. this.maxDay = maxDayParams
  1355. console.log("小:"+this.minDay)
  1356. console.log("大:"+this.maxDay)
  1357. this.getYearArr()
  1358. console.log(this.showMonths)
  1359. },
  1360. // 获取需要的格式的年月日信息
  1361. getYearArr(){
  1362. // 如果有一个日期相差超过366天,按照年,不超过则按天
  1363. var days = this.GetNumberOfDays(this.minDay,this.maxDay)
  1364. if(days >= 365){
  1365. //需要记录月份
  1366. this.IsShowyear = true
  1367. }else{
  1368. //需要记录天数
  1369. this.IsShowyear = true
  1370. }
  1371. // 获取需要格式的年月信息
  1372. let yearArr = []; // 存年
  1373. let minYear = new Date(this.minDay).getFullYear();
  1374. let maxYear = new Date(this.maxDay).getFullYear();
  1375. // 保存年
  1376. if(minYear === maxYear){
  1377. yearArr.push({
  1378. year: minYear+"",
  1379. months: [], // 放月的数组
  1380. days: []
  1381. })
  1382. }else{
  1383. for(let i = minYear;i <= maxYear;i++){
  1384. yearArr.push({
  1385. year: i+"",
  1386. months: [], // 放月的数组
  1387. days: []
  1388. })
  1389. }
  1390. }
  1391. // 保存月
  1392. for(let i = 0;i < yearArr.length;i++){
  1393. let minMonth = 1
  1394. if(i === 0){
  1395. minMonth = new Date(this.minDay).getMonth() + 1;
  1396. }
  1397. // 1.eg:2016年9月 至 2019年01月
  1398. // 2.如果只有一个年,那么月份就是最小月到最大月
  1399. if(yearArr.length > 1){
  1400. // 如果是最后一年,那么就要判断是否到最后一个月
  1401. if(yearArr.length - 1 === i){
  1402. let maxMonth = new Date(this.maxDay).getMonth() + 1;
  1403. let _maxDay = new Date(this.maxDay).getDate() // 最大日期 天数
  1404. let j = 1
  1405. while(j <= maxMonth){
  1406. let monthsDays = this.getLastDay(yearArr[i].year, j); // 获取月份一共有多少天
  1407. let timestampstr = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-" + monthsDays)
  1408. let timestampstr1 = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-01")
  1409. yearArr[i].months.push({str:j+"月",num:j,endTimeStamp:timestampstr,beginTimeStamp:timestampstr1});// 记录最大最小的时间戳
  1410. // 如果显示月|天 才用记录天
  1411. if(!this.IsShowyear){
  1412. yearArr[i].days[yearArr[i].days.length] = {year: "",month: "",daysArr: {}}
  1413. yearArr[i].days[yearArr[i].days.length - 1].year = yearArr[i].year // 赋值年
  1414. yearArr[i].days[yearArr[i].days.length - 1].month = j; // 赋值月
  1415. yearArr[i].days[yearArr[i].days.length - 1].daysArr = []
  1416. // 如果结束月,不是到本月最后一天,而是截止到最
  1417. if(j === maxMonth){
  1418. monthsDays = _maxDay
  1419. }
  1420. for(let k = 1; k <= monthsDays; k++){
  1421. timestampstr = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-" + (k > 9 ? k : '0'+k))
  1422. yearArr[i].days[yearArr[i].days.length - 1].daysArr.push({day: k+"",timestamp:timestampstr});// 赋值天
  1423. }
  1424. }
  1425. j++
  1426. }
  1427. }else{
  1428. if(i === 0){
  1429. let j = minMonth
  1430. let _minDay = new Date(this.minDay).getDate() // 最小日期 天数
  1431. while(j <= 12){
  1432. let monthsDays = this.getLastDay(yearArr[i].year, j); // 获取月份一共有多少天
  1433. let timestampstr = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-" + monthsDays)
  1434. let timestampstr1 = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-01")
  1435. yearArr[i].months.push({str:j+"月",num:j,endTimeStamp:timestampstr,beginTimeStamp:timestampstr1});// 记录最大最小的时间戳
  1436. // 如果显示月|天 才用记录天
  1437. if(!this.IsShowyear){
  1438. yearArr[i].days[yearArr[i].days.length] = {year: "",month: "",daysArr: {}}
  1439. yearArr[i].days[yearArr[i].days.length - 1].year = yearArr[i].year // 赋值月
  1440. yearArr[i].days[yearArr[i].days.length - 1].month = j // 赋值月
  1441. yearArr[i].days[yearArr[i].days.length - 1].daysArr = []
  1442. for(let k = 1; k <= monthsDays; k++){
  1443. // 如果开始月,就不从1日开始,而是从最开始的日期那天开始算起
  1444. if(k === 1 && j === minMonth){
  1445. k = _minDay
  1446. }
  1447. timestampstr = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-" + (k > 9 ? k : '0'+k))
  1448. yearArr[i].days[yearArr[i].days.length - 1].daysArr.push({day: k+"",timestamp:timestampstr});// 赋值天
  1449. }
  1450. }
  1451. j++
  1452. }
  1453. }else{
  1454. let j = 1
  1455. while(j <= 12){
  1456. let monthsDays = this.getLastDay(yearArr[i].year, j); // 获取月份一共有多少天
  1457. let timestampstr = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-" + monthsDays)
  1458. let timestampstr1 = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-01")
  1459. yearArr[i].months.push({str:j+"月",num:j,endTimeStamp:timestampstr,beginTimeStamp:timestampstr1});// 记录最大最小的时间戳
  1460. // 如果显示月|天 才用记录天
  1461. if(!this.IsShowyear){
  1462. yearArr[i].days[yearArr[i].days.length] = {year: "",month: "",daysArr: {}}
  1463. yearArr[i].days[yearArr[i].days.length - 1].year = yearArr[i].year // 赋值年
  1464. yearArr[i].days[yearArr[i].days.length - 1].month = j // 赋值月
  1465. yearArr[i].days[yearArr[i].days.length - 1].daysArr = []
  1466. for(let k = 1; k <= monthsDays; k++){
  1467. timestampstr = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-" + (k > 9 ? k : '0'+k))
  1468. yearArr[i].days[yearArr[i].days.length - 1].daysArr.push({day: k+"",timestamp:timestampstr});// 赋值天
  1469. }
  1470. }
  1471. j++
  1472. }
  1473. }
  1474. }
  1475. }else{
  1476. // 如果只有一年那么没有必要判断是否记录天
  1477. let maxMonth = new Date(this.maxDay).getMonth() + 1;
  1478. let _minMonth = minMonth
  1479. let _minDay = new Date(this.minDay).getDate() // 最小日期 天数
  1480. let _maxDay = new Date(this.maxDay).getDate() // 最大日期 天数
  1481. while(_minMonth <= maxMonth){
  1482. let monthsDays = this.getLastDay(yearArr[i].year, _minMonth); // 获取月份一共有多少天
  1483. let timestampstr = this.getTimeStamp(yearArr[i].year +"-"+ (_minMonth > 9 ? _minMonth : '0'+_minMonth) + "-" + monthsDays)
  1484. let timestampstr1 = this.getTimeStamp(yearArr[i].year +"-"+ (_minMonth > 9 ? _minMonth : '0'+_minMonth) + "-01")
  1485. yearArr[i].months.push({str:_minMonth+"月",num:_minMonth,endTimeStamp:timestampstr,beginTimeStamp:timestampstr1});// 记录最大最小的时间戳
  1486. yearArr[i].days[yearArr[i].days.length] = {year: "",month: "",daysArr: {}}
  1487. yearArr[i].days[yearArr[i].days.length - 1].year = yearArr[i].year // 赋值月
  1488. yearArr[i].days[yearArr[i].days.length - 1].month = _minMonth // 赋值月
  1489. yearArr[i].days[yearArr[i].days.length - 1].daysArr = []
  1490. // 如果结束月,不是到本月最后一天,而是截止到最
  1491. if(_minMonth === maxMonth){
  1492. monthsDays = _maxDay
  1493. }
  1494. for(let k = 1; k <= monthsDays; k++){
  1495. // 如果开始月,就不从1日开始,而是从最开始的日期那天开始算起
  1496. if(k === 1 && _minMonth === minMonth){
  1497. k = _minDay
  1498. }
  1499. timestampstr = this.getTimeStamp(yearArr[i].year +"-"+ (_minMonth > 9 ? _minMonth : '0'+_minMonth) + "-" + (k > 9 ? k : '0'+k))
  1500. yearArr[i].days[yearArr[i].days.length - 1].daysArr.push({day: k+"",timestamp:timestampstr});// 赋值天
  1501. }
  1502. _minMonth++
  1503. }
  1504. }
  1505. }
  1506. this.showMonths = yearArr
  1507. },
  1508. // 获取月的最后一天
  1509. getLastDay(myyear, mymonth){
  1510. var new_date = new Date(myyear, mymonth, 0);
  1511. return new_date.getDate();
  1512. },
  1513. // 获得天数
  1514. GetNumberOfDays(date1,date2){
  1515. //date1:开始日期,date2结束日期
  1516. var a1 = Date.parse(new Date(date1));
  1517. var a2 = Date.parse(new Date(date2));
  1518. var day = parseInt((a2-a1)/ 86400000);//核心:时间戳相减,然后除以天数
  1519. return day
  1520. },
  1521. // 时间比较 true 比大
  1522. compareDate(dateTime1,dateTime2,condition = true)
  1523. {
  1524. var formatDate1 = new Date(dateTime1)
  1525. var formatDate2 = new Date(dateTime2)
  1526. if(formatDate1 >= formatDate2)
  1527. {
  1528. return condition ? dateTime1 : dateTime2
  1529. }
  1530. else
  1531. {
  1532. return condition ? dateTime2 : dateTime1
  1533. }
  1534. },
  1535. // 获取时间戳
  1536. getTimeStamp(val){
  1537. return new Date(val).getTime()
  1538. },
  1539. }
  1540. };
  1541. </script>
  1542. <style>
  1543. /* 单元格padding */
  1544. .barchart .el-table--border th:first-child .cell, .el-table--border td:first-child .cell{
  1545. padding: 0px;
  1546. }
  1547. .barchart .el-table th > .cell{
  1548. padding: 0px;
  1549. }
  1550. /* 单元格高度 */
  1551. .barchart .el-table--medium th,.barchart .el-table--medium td {
  1552. padding: 0px 0px !important;
  1553. height: 25px !important;
  1554. }
  1555. .barchart .progressCon{
  1556. padding: 0;
  1557. margin: 0;
  1558. position: relative;
  1559. }
  1560. .barchart .progressUpon{
  1561. background: rgb(38, 84, 124);
  1562. height: 1.5em;
  1563. /* width: calc(100% + 2px); // +2是因为边框线为2px*/
  1564. z-index: 2;
  1565. position: absolute;
  1566. top: 25%;
  1567. left:0px
  1568. }
  1569. .barchart .progressDownon{
  1570. background: rgb(255,209,102);
  1571. height: 1.5em;
  1572. /* width: calc(100% + 2px); // +2是因为边框线为2px*/
  1573. z-index: 2;
  1574. position: absolute;
  1575. top: 25%;
  1576. left:0px
  1577. }
  1578. </style>