index.vue 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377
  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="handleDoc(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="handleDoc(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="doc.title" :visible.sync="doc.open" width="700px" append-to-body>
  313. <el-upload
  314. ref="doc"
  315. :limit="50"
  316. :headers="doc.headers"
  317. :action="doc.url + '?pType=' + doc.pType + '&pId=' + doc.pId"
  318. :disabled="doc.isUploading"
  319. :on-progress="handleFileDocProgress"
  320. :on-success="handleFileDocSuccess"
  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="doc.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="doc.open = false">{{ $t('返 回') }}</el-button>
  373. </div>
  374. </el-dialog>
  375. <!-- 反馈对话框 -->
  376. <el-dialog v-dialogDrag :title="feedbackDialog.title" :visible.sync="feedbackDialog.open" width="800px" append-to-body>
  377. <div style="width:700px; margin:0px auto;">
  378. <h3 style="margin-bottom:20px;text-align:center;">学员心得</h3>
  379. <el-table :data="tableData" border style="width: 100%">
  380. <el-table-column prop="id" label="编号" width="50"></el-table-column>
  381. <el-table-column prop="question" label="问题" width="250"></el-table-column>
  382. <el-table-column prop="answer" label="答案"></el-table-column>
  383. </el-table>
  384. <el-table :data="doc.commonfileList" border>
  385. <el-table-column :label="$t('文件名')" align="center" prop="fileName" :show-overflow-tooltip="true">
  386. <template slot-scope="scope">
  387. <a class="link-type" @click="handleDownload(scope.row)">
  388. <span>{{ scope.row.fileName }}</span>
  389. </a>
  390. </template>
  391. </el-table-column>
  392. <el-table-column :label="$t('大小(Kb)')" align="center" prop="fileSize" :show-overflow-tooltip="true" width="80" />
  393. <el-table-column :label="$t('上传人')" align="center" prop="creator" :show-overflow-tooltip="true" width="120"/>
  394. <el-table-column :label="$t('操作')" align="center" width="120" class-name="small-padding fixed-width">
  395. <template slot-scope="scope">
  396. <el-button
  397. v-if="scope.row.fileName.endsWith('pdf')"
  398. size="mini"
  399. type="text"
  400. icon="el-icon-view"
  401. @click="handleSee(scope.row)"
  402. >{{ $t('预览') }}</el-button>
  403. <el-button
  404. size="mini"
  405. type="text"
  406. icon="el-icon-download"
  407. @click="handleDownload(scope.row)"
  408. >{{ $t('下载') }}</el-button>
  409. <el-button
  410. size="mini"
  411. type="text"
  412. icon="el-icon-delete"
  413. @click="handleDeleteDoc(scope.row)"
  414. >{{ $t('删除') }}</el-button>
  415. </template>
  416. </el-table-column>
  417. </el-table>
  418. <h3 style="margin-top:30px;margin-bottom:20px;text-align:center;">导师反馈</h3>
  419. <el-form>
  420. <el-form-item>
  421. <editor v-model="feedbackParams.mentorFeedback" :min-height="192"/>
  422. </el-form-item>
  423. </el-form>
  424. <div style="text-align:center;">
  425. <el-button @click="handleApprove()" type="success" size="medium" style="margin-right:25px;">{{ $t('通 过') }}</el-button>
  426. <el-button @click="handleReject()" type="danger" size="medium">{{ $t('驳 回') }}</el-button>
  427. </div>
  428. </div>
  429. </el-dialog>
  430. <plan-approve v-if="planApproveVisible" ref="planApprove" @refreshDataList="getList"></plan-approve>
  431. </div>
  432. </template>
  433. <script>
  434. import { addFeedback } from "@/api/training/spec/feedback";
  435. import { getAnswerByPlanIdAndQuestionId } from "@/api/training/spec/answer";
  436. import {
  437. getPlan,
  438. listPlanByYearId,
  439. delPlan,
  440. addPlan,
  441. updatePlan,
  442. updatePlan2,
  443. exportPlan,
  444. importTemplate,
  445. } from "@/api/training/spec/plan";
  446. import {
  447. allFileList,
  448. delCommonfile
  449. } from "@/api/common/commonfile";
  450. import { treeselect } from "@/api/system/dept";
  451. import { getToken } from "@/utils/auth";
  452. import PlanApprove from "./plan-approve"
  453. import Treeselect from "@riophae/vue-treeselect";
  454. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  455. import {getYearplan} from "@/api/training/spec/yearplan";
  456. import Editor from '@/components/Editor';
  457. export default {
  458. name: "MyPlan",
  459. components: {
  460. Treeselect,
  461. PlanApprove,
  462. Editor
  463. },
  464. data() {
  465. return {
  466. // 开始日期不能跨年 不能小于当前日期
  467. pickerOptionsStartDate: {
  468. disabledDate(time) {
  469. return time.getYear() != new Date().getYear() || time.getTime() < Date.now();
  470. }
  471. },
  472. // 结束日期不能跨年
  473. pickerOptionsEndDate: {
  474. disabledDate(time) {
  475. return time.getYear() != new Date().getYear();
  476. }
  477. },
  478. // 反馈参数
  479. feedbackParams: {
  480. id: null,
  481. mentorFeedback: null
  482. },
  483. showMonths:[],
  484. minDay:"", // 最小日期
  485. maxDay:"", // 最大日期
  486. IsShowyear:true, // 显示年|月 、 月|日
  487. // 查看培养详情参数
  488. detail: {
  489. // 是否显示弹出层(报告附件)
  490. open: false,
  491. // 弹出层标题(报告附件)
  492. title: ""
  493. },
  494. // 反馈对话框参数
  495. feedbackDialog: {
  496. id: 0,
  497. // 是否显示弹出层(报告附件)
  498. open: false,
  499. // 弹出层标题(报告附件)
  500. title: ""
  501. },
  502. // 遮罩层
  503. loading: true,
  504. planApproveVisible: false,
  505. // 选中数组
  506. ids: [],
  507. dataListSelections: [],
  508. // 非单个禁用
  509. single: true,
  510. // 非多个禁用
  511. multiple: true,
  512. // 显示搜索条件
  513. showSearch: false,
  514. // 总条数
  515. total: 0,
  516. // 培养计划表格数据
  517. planList: [],
  518. // 弹出层标题
  519. title: "",
  520. // 操作
  521. operation: "",
  522. // 部门树选项
  523. deptOptions: undefined,
  524. clientHeight:300,
  525. // 是否显示弹出层
  526. open: false,
  527. // 学习状态字典
  528. studyStateOptions: [],
  529. approveStatusOptions: [],
  530. // 学员列表
  531. successorOptions: [],
  532. // 包含导师ID的查询对象
  533. queryObject: {
  534. mentorStaffId: ""
  535. },
  536. // 用户导入参数
  537. upload: {
  538. // 是否显示弹出层(用户导入)
  539. open: false,
  540. // 弹出层标题(用户导入)
  541. title: "",
  542. // 是否禁用上传
  543. isUploading: false,
  544. // 是否更新已经存在的用户数据
  545. updateSupport: 0,
  546. // 设置上传的请求头部
  547. headers: { Authorization: "Bearer " + getToken() },
  548. // 上传的地址
  549. url: process.env.VUE_APP_BASE_API + "/spec/plan/importData"
  550. },
  551. // 报告附件参数
  552. doc: {
  553. file: "",
  554. // 是否显示弹出层(报告附件)
  555. open: false,
  556. // 弹出层标题(报告附件)
  557. title: "",
  558. // 是否禁用上传
  559. isUploading: false,
  560. // 是否更新已经存在的用户数据
  561. updateSupport: 0,
  562. // 报告附件上传位置编号
  563. ids: 0,
  564. // 设置上传的请求头部
  565. headers: { Authorization: "Bearer " + getToken() },
  566. // 上传的地址
  567. url: process.env.VUE_APP_BASE_API + "/common/commonfile/uploadFile",
  568. commonfileList: null,
  569. queryParams: {
  570. pId: null,
  571. pType: 'plan'
  572. },
  573. pType: 'plan',
  574. pId: null
  575. },
  576. // 查询参数
  577. queryParams: {
  578. pageNum: 1,
  579. pageSize: 20,
  580. staffId: null,
  581. plantName: null,
  582. startDate: null,
  583. endDate: null,
  584. classHour: null,
  585. studyState: null,
  586. yearPlanId: null
  587. },
  588. // 表单参数
  589. form: {},
  590. // 表单校验
  591. rules: {
  592. },
  593. // pdf文件参数
  594. pdf : {
  595. title: '',
  596. pdfUrl: '',
  597. numPages: null,
  598. open: false,
  599. pageNum: 1,
  600. pageTotalNum: 1,
  601. loadedRatio: 0,
  602. },
  603. // 表格参数
  604. tableData: [],
  605. };
  606. },
  607. watch: {
  608. // 根据名称筛选部门树
  609. deptName(val) {
  610. this.$refs.tree.filter(val);
  611. }
  612. },
  613. computed:{
  614. // 获取最小日期-月开始时间戳
  615. minDayTimeStamp() {
  616. if(this.IsShowyear){
  617. return this.showMonths[0].months[0].beginTimeStamp
  618. }else{
  619. return this.showMonths[0].days[0].daysArr[0].timestamp
  620. }
  621. },
  622. // 获取最大日期时间戳
  623. maxDayTimeStamp() {
  624. let Length = this.showMonths.length // 年有多少个
  625. // 如果显示年|月 与 月|日 是不同的
  626. if(this.IsShowyear){
  627. let monthsLength = this.showMonths[Length - 1].months.length //月有多少个
  628. return this.showMonths[Length - 1].months[monthsLength - 1].endTimeStamp
  629. }else{
  630. let daysLength = this.showMonths[Length - 1].days.length
  631. let daysarrLength = this.showMonths[Length - 1].days[daysLength - 1].daysArr.length //天有多少个
  632. return this.showMonths[Length - 1].days[daysLength - 1].daysArr[daysarrLength - 1].timestamp + 86400000 //+86400000 是因为时间戳都是0点这样+1天的时间戳,就表示最晚一天的最后的时间
  633. }
  634. },
  635. // 最大日期与最小日期的时间戳差
  636. maxAndminDayTimeStamp() {
  637. return this.maxDayTimeStamp - this.minDayTimeStamp
  638. },
  639. // 获取日期单元格宽度 => 如果返回0则只用之前第一版的计算方法
  640. getCellDateWidth() {
  641. let num = 0 // 获取日期单元格数量
  642. if(this.IsShowyear){
  643. // 月数量
  644. for(let i = 0;i < this.showMonths.length;i++){
  645. num += this.showMonths[i].months.length
  646. }
  647. }else{
  648. // 天数量
  649. for(let i = 0;i < this.showMonths.length;i++){
  650. for(let j = 0;j < this.showMonths[i].days.length;j++){
  651. num += this.showMonths[i].days[j].daysArr.length
  652. }
  653. }
  654. }
  655. // 每个单元格最小30宽度
  656. let MaxWidth = window.screen.width
  657. let CellNum = MaxWidth / 30 > 0 ? MaxWidth / 30 : 0
  658. if(num >= CellNum){ // 页面宽 / 单元格最小宽度 = 最多放下的值
  659. return num * 30
  660. }else{
  661. // 单元格的值,就不能是最小值30了
  662. // 需要获取dom的宽度,在进行计算,但是dom还未渲染完成,因此这里就不考虑了,直接只用第一版的方法动态计算
  663. // TODO
  664. return 0
  665. }
  666. }
  667. },
  668. created() {
  669. //设置表格高度对应屏幕高度
  670. this.$nextTick(() => {
  671. this.clientHeight = document.body.clientHeight -250
  672. })
  673. const yearId = this.$route.params && this.$route.params.yearId;
  674. // 设置查询参数年度计划编号
  675. this.queryParams.yearPlanId = yearId;
  676. this.getList();
  677. this.getTreeselect();
  678. this.getDicts("st_study_state").then(response => {
  679. this.studyStateOptions = response.data;
  680. });
  681. this.getDicts("spec_training_approve_status").then(response => {
  682. this.approveStatusOptions = response.data;
  683. });
  684. },
  685. methods: {
  686. /** 单元格样式 */
  687. tableCellStyle (row, column, rowIndex, columnIndex) {
  688. // 超时学习突出显示
  689. if (row.column.label === "实际完成日期" && row.row.dateOfCompletion > row.row.endDate) {
  690. return "background: #FFEEEE"
  691. }
  692. // 修改过的计划突出显示
  693. if (row.column.label === "修改人" && row.row.updateBy!=null) {
  694. return "background: #FFFFDB"
  695. }
  696. if (row.column.label === "修改时间" && row.row.updatedate!=null) {
  697. return "background: #FFFFDB"
  698. }
  699. },
  700. /** 通过处理 */
  701. handleApprove() {
  702. this.feedbackParams.planId = this.feedbackDialog.id;
  703. addFeedback(this.feedbackParams).then(response => {
  704. // 后期需要发邮件通知学员
  705. this.feedbackDialog.open = false;
  706. });
  707. },
  708. /** 驳回处理 */
  709. handleReject() {
  710. this.feedbackParams.planId = this.feedbackDialog.id;
  711. addFeedback(this.feedbackParams).then(response => {
  712. // 后期需要发邮件通知学员
  713. this.feedbackDialog.open = false;
  714. });
  715. },
  716. /** 反馈处理 */
  717. handleFeedback(row) {
  718. this.tableData = [];
  719. let feedback1 = {};
  720. feedback1.planId = row.id;
  721. feedback1.questionId = 1;
  722. let feedback2 = {};
  723. feedback2.planId = row.id;
  724. feedback2.questionId = 2;
  725. let feedback3 = {};
  726. feedback3.planId = row.id;
  727. feedback3.questionId = 3;
  728. let answerObj1 = {};
  729. let answerObj2 = {};
  730. let answerObj3 = {};
  731. getAnswerByPlanIdAndQuestionId(feedback1).then(response => {
  732. let data = response.data;
  733. answerObj1 = { id: feedback1.questionId, question: data.question, answer: data.answer};
  734. return getAnswerByPlanIdAndQuestionId(feedback2);
  735. }).then(response => {
  736. let data = response.data;
  737. answerObj2 = { id: feedback2.questionId, question: data.question, answer: data.answer};
  738. return getAnswerByPlanIdAndQuestionId(feedback3);
  739. }).then(response => {
  740. let data = response.data;
  741. answerObj3 = { id: feedback3.questionId, question: data.question, answer: data.answer};
  742. this.tableData.push(answerObj1);
  743. this.tableData.push(answerObj2);
  744. this.tableData.push(answerObj3);
  745. this.feedbackDialog.id = row.id;
  746. this.feedbackDialog.title = row.staffName + row.plantName + "学习情况反馈";
  747. this.feedbackDialog.open = true;
  748. });
  749. },
  750. /** 文件下载处理 */
  751. handleDownload(row) {
  752. var name = row.fileName;
  753. var url = row.fileUrl;
  754. var suffix = url.substring(url.lastIndexOf("."), url.length);
  755. const a = document.createElement('a')
  756. a.setAttribute('download', name)
  757. a.setAttribute('target', '_blank')
  758. a.setAttribute('href', process.env.VUE_APP_BASE_API + url)
  759. a.click()
  760. },
  761. openPdf(){
  762. window.open(this.pdf.pdfUrl);//path是文件的全路径地址
  763. },
  764. handleSee (row){
  765. this.pdf.open =true
  766. this.pdf.title = row.fileName
  767. this.pdf.pdfUrl = process.env.VUE_APP_BASE_API +'/pdf/web/viewer.html?file=' + process.env.VUE_APP_BASE_API + row.fileUrl
  768. },
  769. /** 报告附件按钮操作 */
  770. handleDoc(row) {
  771. this.doc.id = row.id;
  772. this.doc.title = row.plantName + this.$t('附件');
  773. this.doc.open = true;
  774. this.doc.queryParams.pId = row.id
  775. this.doc.pId = row.id
  776. this.getFileList()
  777. this.$nextTick(() => {
  778. this.$refs.doc.clearFiles()
  779. })
  780. },
  781. getFileList (){
  782. allFileList(this.doc.queryParams).then(response => {
  783. this.doc.commonfileList = response;
  784. });
  785. },
  786. /** 附件上传中处理 */
  787. handleFileDocProgress(event, file, fileList) {
  788. this.doc.file = file;
  789. this.doc.isUploading = true;
  790. },
  791. /** 附件上传成功处理 */
  792. handleFileDocSuccess(response, file, fileList) {
  793. this.doc.isUploading = false;
  794. this.$alert(response.msg, this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  795. this.getFileList()
  796. },
  797. /** 删除按钮操作 */
  798. handleDeleteDoc(row) {
  799. const ids = row.id || this.ids;
  800. this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
  801. confirmButtonText: this.$t('确定'),
  802. cancelButtonText: this.$t('取消'),
  803. type: "warning"
  804. }).then(function() {
  805. return delCommonfile(ids);
  806. }).then(() => {
  807. this.getFileList()
  808. this.msgSuccess(this.$t('删除成功'));
  809. })
  810. },
  811. /** 查询培训计划列表 */
  812. getList() {
  813. this.loading = true;
  814. listPlanByYearId(this.queryParams).then(response => {
  815. this.planList = response.rows;
  816. this.total = response.total;
  817. this.setrowspans() // 设置合并
  818. this.getChartTitle() // 渲染的信息
  819. this.$nextTick(() => {
  820. this.$refs.planTable.doLayout(); // 解决表格错位
  821. });
  822. this.loading = false;
  823. });
  824. },
  825. /** 查询部门下拉树结构 */
  826. getTreeselect() {
  827. treeselect().then(response => {
  828. this.deptOptions = response.data;
  829. });
  830. },
  831. /** 学习状态字典翻译 */
  832. studyStateFormat(row, column) {
  833. return this.selectDictLabel(this.studyStateOptions, row.studyState);
  834. },
  835. // 申请状态字典翻译
  836. approveStatusFormat(row, column) {
  837. return this.selectDictLabel(this.approveStatusOptions, row.approveStatus);
  838. },
  839. approveStatusType (type) {
  840. if (type == 0) {
  841. return 'danger'
  842. }else if (type == 1) {
  843. return 'success'
  844. }else if (type == 2) {
  845. return 'danger'
  846. }else {
  847. return 'info'
  848. }
  849. },
  850. /** 取消按钮 */
  851. cancel() {
  852. this.open = false;
  853. this.reset();
  854. },
  855. /** 表单重置 */
  856. reset() {
  857. this.form = {
  858. id: null,
  859. staffId: null,
  860. plantName: null,
  861. delFlag: null,
  862. createrCode: null,
  863. createdate: null,
  864. updaterCode: null,
  865. updatedate: null,
  866. deptId: null,
  867. startDate: null,
  868. endDate: null,
  869. classHour: null,
  870. classContent: null,
  871. studyState: null
  872. };
  873. this.resetForm("form");
  874. },
  875. /** 搜索按钮操作 */
  876. handleQuery() {
  877. this.queryParams.pageNum = 1;
  878. this.getList();
  879. },
  880. /** 重置按钮操作 */
  881. resetQuery() {
  882. this.resetForm("queryForm");
  883. this.handleQuery();
  884. },
  885. /** 多选框选中数据 */
  886. handleSelectionChange(selection) {
  887. this.ids = selection.map(item => item.id)
  888. this.single = selection.length!==1
  889. this.multiple = !selection.length
  890. this.dataListSelections = selection
  891. },
  892. /** 新增按钮操作 */
  893. handleAdd() {
  894. this.reset();
  895. getYearplan(this.queryParams.yearPlanId).then(response => {
  896. this.form.staffId = response.data.staffId.toString();
  897. this.open = true;
  898. this.title = "添加培养计划";
  899. this.operation = "modify";
  900. });
  901. this.open = true;
  902. this.title = "添加培养计划";
  903. this.operation = "add";
  904. },
  905. /** 修改按钮操作 */
  906. handleUpdate(row) {
  907. this.reset();
  908. const id = row.id || this.ids
  909. getPlan(id).then(response => {
  910. this.form = response.data;
  911. this.open = true;
  912. this.title = "修改培养计划";
  913. this.operation = "modify";
  914. });
  915. },
  916. /** 提交按钮 */
  917. submitForm() {
  918. this.$refs["form"].validate(valid => {
  919. if (valid) {
  920. if (this.form.id != null) {
  921. updatePlan(this.form).then(response => {
  922. this.msgSuccess("修改成功");
  923. this.open = false;
  924. this.getList();
  925. });
  926. } else {
  927. // 设置表单参数年度计划编号
  928. this.form.yearPlanId = this.queryParams.yearPlanId;
  929. addPlan(this.form).then(response => {
  930. this.msgSuccess("新增成功");
  931. this.open = false;
  932. this.getList();
  933. });
  934. }
  935. }
  936. });
  937. },
  938. /** 删除按钮操作 */
  939. handleDelete(row) {
  940. const ids = row.id || this.ids;
  941. this.$confirm('是否确认删除?', "警告", {
  942. confirmButtonText: "确定",
  943. cancelButtonText: "取消",
  944. type: "warning"
  945. }).then(function() {
  946. return delPlan(ids);
  947. }).then(() => {
  948. this.getList();
  949. this.msgSuccess("删除成功");
  950. })
  951. },
  952. /** 导出按钮操作 */
  953. handleExport() {
  954. const queryParams = this.queryParams;
  955. this.$confirm('是否确认导出所有培养计划数据项?', "警告", {
  956. confirmButtonText: "确定",
  957. cancelButtonText: "取消",
  958. type: "warning"
  959. }).then(function() {
  960. return exportPlan(queryParams);
  961. }).then(response => {
  962. this.download(response.msg);
  963. })
  964. },
  965. /** 导入按钮操作 */
  966. handleImport() {
  967. this.upload.title = "用户导入";
  968. this.upload.open = true;
  969. },
  970. /** 下载模板操作 */
  971. importTemplate() {
  972. importTemplate().then(response => {
  973. this.download(response.msg);
  974. });
  975. },
  976. /** 文件上传中处理 */
  977. handleFileUploadProgress(event, file, fileList) {
  978. this.upload.isUploading = true;
  979. },
  980. /** 文件上传成功处理 */
  981. handleFileSuccess(response, file, fileList) {
  982. this.upload.open = false;
  983. this.upload.isUploading = false;
  984. this.$refs.upload.clearFiles();
  985. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  986. this.getList();
  987. },
  988. /** 提交上传文件 */
  989. submitFileForm() {
  990. this.$refs.upload.submit();
  991. },
  992. addAprrove (row, type) {
  993. var rows = row ? [row] : this.dataListSelections.map(item => {
  994. return item
  995. })
  996. this.planApproveVisible = true
  997. console.log(rows)
  998. console.log(type)
  999. this.$nextTick(() => {
  1000. this.$refs.planApprove.init(rows, type)
  1001. })
  1002. },
  1003. optimizeCalcWidth(val) {
  1004. let SumNum = this.maxAndminDayTimeStamp
  1005. let diffNum = this.IsShowyear ? val.endTimeStamp - val.beginTimeStamp : val.endTimeStamp + 84600000 - val.beginTimeStamp // 结束日期 - 开始日期
  1006. let rate = Math.round(diffNum / SumNum * 10000) / 100.00 //得到百分比
  1007. let widthPx = this.getCellDateWidth * rate / 100.00
  1008. return widthPx + 'px'
  1009. },
  1010. optimizeCalcLeft(val) {
  1011. let SumNum = this.maxAndminDayTimeStamp
  1012. let diffNum = val.beginTimeStamp - this.minDayTimeStamp // 开始日期 - 整个月开始日期
  1013. let rate = Math.round(diffNum / SumNum * 10000) / 100.00 //得到百分比
  1014. let leftPx = this.getCellDateWidth * rate / 100.00
  1015. return leftPx + 'px'
  1016. },
  1017. // 计算图表的Left
  1018. calcLeft(val,date) {
  1019. // 如果本月的最大时间戳都没有结束时间长,那么就可判断
  1020. if(val.endTimeStamp > date.endTimeStamp){
  1021. // 如果本月开始日期小于开始日期
  1022. if(val.beginTimeStamp > date.beginTimeStamp){
  1023. // 进行判断
  1024. let diffNum = date.endTimeStamp - val.beginTimeStamp
  1025. let SumNum = date.endTimeStamp - date.beginTimeStamp
  1026. let rate = 100 - Math.round(diffNum / SumNum * 10000) / 100.00
  1027. // 位置判断
  1028. return rate+"%"
  1029. }
  1030. }else if(val.endTimeStamp > date.beginTimeStamp && val.endTimeStamp < date.endTimeStamp){
  1031. // 进行判断
  1032. if(val.beginTimeStamp > date.beginTimeStamp){
  1033. // 都在一个单元格中
  1034. let diffNum = val.beginTimeStamp - date.beginTimeStamp
  1035. let SumNum = date.endTimeStamp - date.beginTimeStamp
  1036. let rate = Math.round(diffNum / SumNum * 10000) / 100.00
  1037. // 位置判断
  1038. return rate+"%"
  1039. }
  1040. }
  1041. return '0px'
  1042. },
  1043. // 计算图表的Width
  1044. calcwidth(val,date) {
  1045. if(this.IsShowyear){
  1046. // 如果是 年|月
  1047. // 1. 如果本月的最大时间戳都没有结束时间长,那么就可设置100%
  1048. // 2. 如果本月的最小时间戳比结束时间长,那么设置0
  1049. // 3. 如果本月的最小时间戳没有结束时间长,那么进行判断
  1050. if(val.endTimeStamp > date.endTimeStamp){
  1051. // 如果本月开始日期小于开始日期
  1052. if(val.beginTimeStamp > date.beginTimeStamp){
  1053. // 进行判断
  1054. let diffNum = date.endTimeStamp - val.beginTimeStamp
  1055. let SumNum = date.endTimeStamp - date.beginTimeStamp
  1056. let rate = Math.round(diffNum / SumNum * 10000) / 100.00
  1057. return 'calc('+ rate +'% + 2px)' // 结束时间超过本月最大时间戳直接+2px
  1058. }
  1059. return 'calc(100% + 2px)'
  1060. }else if(val.endTimeStamp < date.beginTimeStamp){
  1061. return '0px'
  1062. }else if(val.endTimeStamp > date.beginTimeStamp && val.endTimeStamp <= date.endTimeStamp){
  1063. // 进行判断
  1064. if(val.beginTimeStamp > date.beginTimeStamp){
  1065. // 都在一个单元格中
  1066. let SumNum = date.endTimeStamp - date.beginTimeStamp // 全月多少数
  1067. let diffNum = val.endTimeStamp - val.beginTimeStamp // 过程多少数
  1068. diffNum = diffNum === 0 ? 86400000 : diffNum
  1069. let rate = Math.round(diffNum / SumNum * 10000) / 100.00
  1070. return 'calc('+ rate +'%)'
  1071. }else{
  1072. // 不在一个单元格中,则不需要判断任何信息
  1073. let diffNum = val.endTimeStamp - date.beginTimeStamp
  1074. let SumNum = date.endTimeStamp - date.beginTimeStamp
  1075. let rate = Math.round(diffNum / SumNum * 10000) / 100.00
  1076. return 'calc('+ rate +'%)'
  1077. }
  1078. }
  1079. }
  1080. return '0px'
  1081. },
  1082. //获得数据相同的行数(网络复制)
  1083. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  1084. if (columnIndex === 0) {
  1085. return {
  1086. rowspan: row.rowspan,
  1087. colspan: 1
  1088. };
  1089. }
  1090. },
  1091. // 根据id去分组(网络复制)
  1092. setrowspans() {
  1093. // 先给所有的数据都加一个v.rowspan = 1
  1094. this.planList.forEach(v => {
  1095. v.rowspan = 1;
  1096. });
  1097. // 双层循环
  1098. for (let i = 0; i < this.planList.length; i++) {
  1099. // 内层循环,上面已经给所有的行都加了v.rowspan = 1
  1100. // 这里进行判断
  1101. // 如果当前行的id和下一行的id相等
  1102. // 就把当前v.rowspan + 1
  1103. // 下一行的v.rowspan - 1
  1104. for (let j = i + 1; j < this.planList.length; j++) {
  1105. //此处可根据相同字段进行合并,此处是根据的id
  1106. if (this.planList[i].id === this.planList[j].id) {
  1107. this.planList[i].rowspan++;
  1108. this.planList[j].rowspan--;
  1109. }
  1110. }
  1111. // 这里跳过已经重复的数据
  1112. i = i + this.planList[i].rowspan - 1;
  1113. }
  1114. },
  1115. // 渲染表格头,首先是年月,如2018年11月
  1116. getChartTitle(startDate, endDate){
  1117. var chartTable = this.planList;
  1118. // 准备日期,为了防止多次赋值属性,导致计算属性重新计算,决定只赋值一次
  1119. let maxDayParams = "",minDayParams = ""
  1120. for(var i = 0; i < chartTable.length; i++){
  1121. var StartDate = chartTable[i].startDate;
  1122. var EndDate = chartTable[i].endDate;
  1123. var mainObj = chartTable[i];
  1124. // 计划日期
  1125. maxDayParams === "" ? maxDayParams = EndDate : ''
  1126. minDayParams === "" ? minDayParams = StartDate : ""
  1127. maxDayParams = this.compareDate(EndDate,maxDayParams,true)
  1128. minDayParams = this.compareDate(StartDate,minDayParams,false)
  1129. var days = this.GetNumberOfDays(StartDate,EndDate) // 计算工期
  1130. this.planList[i].days = days + 1 // 加一是因为没算结算当天
  1131. // 记录时间戳
  1132. this.planList[i].beginTimeStamp = this.getTimeStamp(StartDate)
  1133. this.planList[i].endTimeStamp = this.getTimeStamp(EndDate)
  1134. }
  1135. this.minDay = minDayParams
  1136. this.maxDay = maxDayParams
  1137. console.log("小:"+this.minDay)
  1138. console.log("大:"+this.maxDay)
  1139. this.getYearArr()
  1140. console.log(this.showMonths)
  1141. },
  1142. // 获取需要的格式的年月日信息
  1143. getYearArr(){
  1144. // 如果有一个日期相差超过366天,按照年,不超过则按天
  1145. var days = this.GetNumberOfDays(this.minDay,this.maxDay)
  1146. if(days >= 365){
  1147. //需要记录月份
  1148. this.IsShowyear = true
  1149. }else{
  1150. //需要记录天数
  1151. this.IsShowyear = true
  1152. }
  1153. // 获取需要格式的年月信息
  1154. let yearArr = []; // 存年
  1155. let minYear = new Date(this.minDay).getFullYear();
  1156. let maxYear = new Date(this.maxDay).getFullYear();
  1157. // 保存年
  1158. if(minYear === maxYear){
  1159. yearArr.push({
  1160. year: minYear+"",
  1161. months: [], // 放月的数组
  1162. days: []
  1163. })
  1164. }else{
  1165. for(let i = minYear;i <= maxYear;i++){
  1166. yearArr.push({
  1167. year: i+"",
  1168. months: [], // 放月的数组
  1169. days: []
  1170. })
  1171. }
  1172. }
  1173. // 保存月
  1174. for(let i = 0;i < yearArr.length;i++){
  1175. let minMonth = 1
  1176. if(i === 0){
  1177. minMonth = new Date(this.minDay).getMonth() + 1;
  1178. }
  1179. // 1.eg:2016年9月 至 2019年01月
  1180. // 2.如果只有一个年,那么月份就是最小月到最大月
  1181. if(yearArr.length > 1){
  1182. // 如果是最后一年,那么就要判断是否到最后一个月
  1183. if(yearArr.length - 1 === i){
  1184. let maxMonth = new Date(this.maxDay).getMonth() + 1;
  1185. let _maxDay = new Date(this.maxDay).getDate() // 最大日期 天数
  1186. let j = 1
  1187. while(j <= maxMonth){
  1188. let monthsDays = this.getLastDay(yearArr[i].year, j); // 获取月份一共有多少天
  1189. let timestampstr = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-" + monthsDays)
  1190. let timestampstr1 = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-01")
  1191. yearArr[i].months.push({str:j+"月",num:j,endTimeStamp:timestampstr,beginTimeStamp:timestampstr1});// 记录最大最小的时间戳
  1192. // 如果显示月|天 才用记录天
  1193. if(!this.IsShowyear){
  1194. yearArr[i].days[yearArr[i].days.length] = {year: "",month: "",daysArr: {}}
  1195. yearArr[i].days[yearArr[i].days.length - 1].year = yearArr[i].year // 赋值年
  1196. yearArr[i].days[yearArr[i].days.length - 1].month = j; // 赋值月
  1197. yearArr[i].days[yearArr[i].days.length - 1].daysArr = []
  1198. // 如果结束月,不是到本月最后一天,而是截止到最
  1199. if(j === maxMonth){
  1200. monthsDays = _maxDay
  1201. }
  1202. for(let k = 1; k <= monthsDays; k++){
  1203. timestampstr = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-" + (k > 9 ? k : '0'+k))
  1204. yearArr[i].days[yearArr[i].days.length - 1].daysArr.push({day: k+"",timestamp:timestampstr});// 赋值天
  1205. }
  1206. }
  1207. j++
  1208. }
  1209. }else{
  1210. if(i === 0){
  1211. let j = minMonth
  1212. let _minDay = new Date(this.minDay).getDate() // 最小日期 天数
  1213. while(j <= 12){
  1214. let monthsDays = this.getLastDay(yearArr[i].year, j); // 获取月份一共有多少天
  1215. let timestampstr = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-" + monthsDays)
  1216. let timestampstr1 = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-01")
  1217. yearArr[i].months.push({str:j+"月",num:j,endTimeStamp:timestampstr,beginTimeStamp:timestampstr1});// 记录最大最小的时间戳
  1218. // 如果显示月|天 才用记录天
  1219. if(!this.IsShowyear){
  1220. yearArr[i].days[yearArr[i].days.length] = {year: "",month: "",daysArr: {}}
  1221. yearArr[i].days[yearArr[i].days.length - 1].year = yearArr[i].year // 赋值月
  1222. yearArr[i].days[yearArr[i].days.length - 1].month = j // 赋值月
  1223. yearArr[i].days[yearArr[i].days.length - 1].daysArr = []
  1224. for(let k = 1; k <= monthsDays; k++){
  1225. // 如果开始月,就不从1日开始,而是从最开始的日期那天开始算起
  1226. if(k === 1 && j === minMonth){
  1227. k = _minDay
  1228. }
  1229. timestampstr = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-" + (k > 9 ? k : '0'+k))
  1230. yearArr[i].days[yearArr[i].days.length - 1].daysArr.push({day: k+"",timestamp:timestampstr});// 赋值天
  1231. }
  1232. }
  1233. j++
  1234. }
  1235. }else{
  1236. let j = 1
  1237. while(j <= 12){
  1238. let monthsDays = this.getLastDay(yearArr[i].year, j); // 获取月份一共有多少天
  1239. let timestampstr = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-" + monthsDays)
  1240. let timestampstr1 = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-01")
  1241. yearArr[i].months.push({str:j+"月",num:j,endTimeStamp:timestampstr,beginTimeStamp:timestampstr1});// 记录最大最小的时间戳
  1242. // 如果显示月|天 才用记录天
  1243. if(!this.IsShowyear){
  1244. yearArr[i].days[yearArr[i].days.length] = {year: "",month: "",daysArr: {}}
  1245. yearArr[i].days[yearArr[i].days.length - 1].year = yearArr[i].year // 赋值年
  1246. yearArr[i].days[yearArr[i].days.length - 1].month = j // 赋值月
  1247. yearArr[i].days[yearArr[i].days.length - 1].daysArr = []
  1248. for(let k = 1; k <= monthsDays; k++){
  1249. timestampstr = this.getTimeStamp(yearArr[i].year +"-"+ (j > 9 ? j : '0'+j) + "-" + (k > 9 ? k : '0'+k))
  1250. yearArr[i].days[yearArr[i].days.length - 1].daysArr.push({day: k+"",timestamp:timestampstr});// 赋值天
  1251. }
  1252. }
  1253. j++
  1254. }
  1255. }
  1256. }
  1257. }else{
  1258. // 如果只有一年那么没有必要判断是否记录天
  1259. let maxMonth = new Date(this.maxDay).getMonth() + 1;
  1260. let _minMonth = minMonth
  1261. let _minDay = new Date(this.minDay).getDate() // 最小日期 天数
  1262. let _maxDay = new Date(this.maxDay).getDate() // 最大日期 天数
  1263. while(_minMonth <= maxMonth){
  1264. let monthsDays = this.getLastDay(yearArr[i].year, _minMonth); // 获取月份一共有多少天
  1265. let timestampstr = this.getTimeStamp(yearArr[i].year +"-"+ (_minMonth > 9 ? _minMonth : '0'+_minMonth) + "-" + monthsDays)
  1266. let timestampstr1 = this.getTimeStamp(yearArr[i].year +"-"+ (_minMonth > 9 ? _minMonth : '0'+_minMonth) + "-01")
  1267. yearArr[i].months.push({str:_minMonth+"月",num:_minMonth,endTimeStamp:timestampstr,beginTimeStamp:timestampstr1});// 记录最大最小的时间戳
  1268. yearArr[i].days[yearArr[i].days.length] = {year: "",month: "",daysArr: {}}
  1269. yearArr[i].days[yearArr[i].days.length - 1].year = yearArr[i].year // 赋值月
  1270. yearArr[i].days[yearArr[i].days.length - 1].month = _minMonth // 赋值月
  1271. yearArr[i].days[yearArr[i].days.length - 1].daysArr = []
  1272. // 如果结束月,不是到本月最后一天,而是截止到最
  1273. if(_minMonth === maxMonth){
  1274. monthsDays = _maxDay
  1275. }
  1276. for(let k = 1; k <= monthsDays; k++){
  1277. // 如果开始月,就不从1日开始,而是从最开始的日期那天开始算起
  1278. if(k === 1 && _minMonth === minMonth){
  1279. k = _minDay
  1280. }
  1281. timestampstr = this.getTimeStamp(yearArr[i].year +"-"+ (_minMonth > 9 ? _minMonth : '0'+_minMonth) + "-" + (k > 9 ? k : '0'+k))
  1282. yearArr[i].days[yearArr[i].days.length - 1].daysArr.push({day: k+"",timestamp:timestampstr});// 赋值天
  1283. }
  1284. _minMonth++
  1285. }
  1286. }
  1287. }
  1288. this.showMonths = yearArr
  1289. },
  1290. // 获取月的最后一天
  1291. getLastDay(myyear, mymonth){
  1292. var new_date = new Date(myyear, mymonth, 0);
  1293. return new_date.getDate();
  1294. },
  1295. // 获得天数
  1296. GetNumberOfDays(date1,date2){
  1297. //date1:开始日期,date2结束日期
  1298. var a1 = Date.parse(new Date(date1));
  1299. var a2 = Date.parse(new Date(date2));
  1300. var day = parseInt((a2-a1)/ 86400000);//核心:时间戳相减,然后除以天数
  1301. return day
  1302. },
  1303. // 时间比较 true 比大
  1304. compareDate(dateTime1,dateTime2,condition = true)
  1305. {
  1306. var formatDate1 = new Date(dateTime1)
  1307. var formatDate2 = new Date(dateTime2)
  1308. if(formatDate1 >= formatDate2)
  1309. {
  1310. return condition ? dateTime1 : dateTime2
  1311. }
  1312. else
  1313. {
  1314. return condition ? dateTime2 : dateTime1
  1315. }
  1316. },
  1317. // 获取时间戳
  1318. getTimeStamp(val){
  1319. return new Date(val).getTime()
  1320. },
  1321. }
  1322. };
  1323. </script>
  1324. <style>
  1325. /* 单元格padding */
  1326. .barchart .el-table--border th:first-child .cell, .el-table--border td:first-child .cell{
  1327. padding: 0px;
  1328. }
  1329. .barchart .el-table th > .cell{
  1330. padding: 0px;
  1331. }
  1332. /* 单元格高度 */
  1333. .barchart .el-table--medium th,.barchart .el-table--medium td {
  1334. padding: 0px 0px !important;
  1335. height: 25px !important;
  1336. }
  1337. .barchart .progressCon{
  1338. padding: 0;
  1339. margin: 0;
  1340. position: relative;
  1341. }
  1342. .barchart .progressUpon{
  1343. background: rgb(38, 84, 124);
  1344. height: 1.5em;
  1345. /* width: calc(100% + 2px); // +2是因为边框线为2px*/
  1346. z-index: 2;
  1347. position: absolute;
  1348. top: 25%;
  1349. left:0px
  1350. }
  1351. .barchart .progressDownon{
  1352. background: rgb(255,209,102);
  1353. height: 1.5em;
  1354. /* width: calc(100% + 2px); // +2是因为边框线为2px*/
  1355. z-index: 2;
  1356. position: absolute;
  1357. top: 25%;
  1358. left:0px
  1359. }
  1360. </style>