index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. <!--化学品信息-->
  2. <template>
  3. <div class="app-container ChemicalInfo">
  4. <!--列表页面-->
  5. <div class="ChemicalInfo-page" v-if="pageType == 1">
  6. <el-form :model="queryParamsData" class="form-box" ref="queryForm" :inline="true">
  7. <el-form-item label="关键字" prop="searchValue">
  8. <el-input
  9. maxLength="20"
  10. v-model="queryParamsData.searchValue"
  11. placeholder="化学品名/别名/CAS号"
  12. clearable
  13. size="small"
  14. style="width: 200px"
  15. />
  16. </el-form-item>
  17. <el-form-item label="化学品分类" prop="chemicalClassify">
  18. <el-select v-model="queryParamsData.chemicalClassify" clearable placeholder="请选择化学品分类" style="width:180px;">
  19. <el-option
  20. v-for="item in optionsListOne"
  21. :key="item.id"
  22. :label="item.classifyName"
  23. :value="item.id">
  24. </el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="属性" prop="classifyAttribute">
  28. <el-select v-model="queryParamsData.classifyAttribute" clearable placeholder="请选择属性" style="width:180px;">
  29. <el-option
  30. v-for="item in optionsListTwo"
  31. :key="item.dictValue"
  32. :label="item.dictLabel"
  33. :value="item.dictValue">
  34. </el-option>
  35. </el-select>
  36. </el-form-item>
  37. <!--<el-form-item label="标签类型" prop="labelType">-->
  38. <!--<el-select v-model="queryParamsData.labelType" clearable placeholder="请选择标签类型" style="width:180px;">-->
  39. <!--<el-option-->
  40. <!--v-for="item in optionsList"-->
  41. <!--:key="item.id"-->
  42. <!--:label="item.name"-->
  43. <!--:value="item.id">-->
  44. <!--</el-option>-->
  45. <!--</el-select>-->
  46. <!--</el-form-item>-->
  47. <el-form-item>
  48. <p class="inquire-button-one" @click="handleQuery" style="margin-right:10px;">查询</p>
  49. <p class="reset-button-one" @click="resetQuery">重置</p>
  50. </el-form-item>
  51. <el-form-item style="float: right;">
  52. <el-col :span="1.5" v-hasPermi="['chemical:hxpChemical:add']">
  53. <p class="add-button-one-90"
  54. @click="pageToggle(2)"
  55. ><i class="el-icon-plus"></i>新增</p>
  56. </el-col>
  57. </el-form-item>
  58. <el-form-item style="float: right;">
  59. <el-dropdown @command="exportButton" v-hasPermi="['chemical:hxpChemical:export']">
  60. <div class="form-dropdown-box">
  61. <img src="@/assets/ZDimages/personnelManagement/icon_jzgxx_sc.png">
  62. <p>导出</p>
  63. <img src="@/assets/ZDimages/personnelManagement/icon_jzggl_xljt.png">
  64. </div>
  65. <el-dropdown-menu slot="dropdown">
  66. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;color:#333;" :command="{command:1}">导出全部数据</el-dropdown-item>
  67. <el-dropdown-item style="margin:0 10px;color:#666;" :command="{command:2}">导出选中数据</el-dropdown-item>
  68. </el-dropdown-menu>
  69. </el-dropdown>
  70. </el-form-item>
  71. <el-form-item style="float: right;">
  72. <el-dropdown @command="importButton" v-hasPermi="['chemical:hxpChemical:import']">
  73. <div class="form-dropdown-box">
  74. <img src="@/assets/ZDimages/personnelManagement/icon_jzgxx_dr.png">
  75. <p>导入</p>
  76. <img src="@/assets/ZDimages/personnelManagement/icon_jzggl_xljt.png">
  77. </div>
  78. <el-dropdown-menu slot="dropdown">
  79. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;color:#333;" :command="{command:1}">下载模板</el-dropdown-item>
  80. <el-dropdown-item style="margin:0 10px;color:#666;" :command="{command:2}">导入数据</el-dropdown-item>
  81. </el-dropdown-menu>
  82. </el-dropdown>
  83. </el-form-item>
  84. </el-form>
  85. <el-table border :data="tableList" @selection-change="handleSelectionChange" ref="multipleTable" :row-key="getRowKeys">
  86. <el-table-column type="selection" width="50" align="center" :reserve-selection="true"/>
  87. <el-table-column label="ID" align="center" prop="chemicalNum" width="123px"/>
  88. <el-table-column label="化学品名" align="center" prop="chemicalName" show-overflow-tooltip/>
  89. <el-table-column label="CAS号" align="center" prop="casNum" width="140px"/>
  90. <el-table-column label="分类" align="center" prop="classifyName" width="130px"/>
  91. <el-table-column label="属性" align="center" prop="classifyAttribute" width="150px" show-overflow-tooltip/>
  92. <el-table-column label="形态" align="center" prop="chemicalShapeInfo" width="100px"/>
  93. <!--<el-table-column label="标签类型" align="center" prop="labelContent" width="100px"/>-->
  94. <!--<el-table-column label="验证方式" align="center" prop="verificationContent" width="150px"/>-->
  95. <el-table-column label="创建时间" align="center" prop="createTime" width="170px"/>
  96. <el-table-column label="创建人" align="center" prop="createBy" width="130px"/>
  97. <el-table-column label="操作" align="center" width="280" class-name="small-padding fixed-width" v-if="tableButtonType">
  98. <template slot-scope="scope">
  99. <div class="button-box">
  100. <p class="table-min-button" v-hasPermi="['chemical:hxpChemical:msdsList']" @click="pageToggle(4,scope.row)">MSDS</p>
  101. <p class="table-min-button" v-hasPermi="['chemical:hxpChemical:joinList']" @click="pageToggle(3,scope.row)">关联化学品柜</p>
  102. <el-dropdown @command="moreClick" v-hasPermi="['chemical:hxpChemical:query','chemical:hxpChemical:edit','chemical:hxpChemical:remove']">
  103. <p class="table-min-button">更多>></p>
  104. <el-dropdown-menu slot="dropdown">
  105. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;" :command="{row:scope.row,command:1}" v-hasPermiAnd="['chemical:hxpChemical:query','chemical:hxpChemical:edit']">编辑</el-dropdown-item>
  106. <el-dropdown-item style="margin:0 10px;" :command="{row:scope.row,command:2}" v-hasPermi="['chemical:hxpChemical:remove']">删除</el-dropdown-item>
  107. </el-dropdown-menu>
  108. </el-dropdown>
  109. </div>
  110. </template>
  111. </el-table-column>
  112. </el-table>
  113. <div style="display: flex;height:32px;margin:5px 0 15px;">
  114. <!--<p style="flex:4;"></p>-->
  115. <p style="text-align: left;margin:0;line-height:32px;margin-top:15px;margin-right:20px;font-size:14px;color:#999;">
  116. <i class="el-icon-warning" style="color:#0183FA;"></i>
  117. 已选择 {{selectedNum}} 项
  118. </p>
  119. <div style="flex:5;">
  120. <pagination :page-sizes="[20, 30, 40, 50]"
  121. v-show="total>0"
  122. :total="total"
  123. style="margin:0;"
  124. :page.sync="queryParams.pageNum"
  125. :limit.sync="queryParams.pageSize"
  126. @pagination="getList"
  127. />
  128. </div>
  129. </div>
  130. </div>
  131. <!--新增化学品-->
  132. <add-page v-if="pageType == 2" :addPropsData="addPropsData"></add-page>
  133. <!--关联化学品柜-->
  134. <list-page v-if="pageType == 3" :listPropsData="listPropsData"></list-page>
  135. <msds-page v-if="pageType == 4" :msdsPropsData="msdsPropsData"></msds-page>
  136. <!--导入窗口-->
  137. <el-dialog title="导入数据" :visible.sync="importOpen" @close="importOpenOff" width="600px" append-to-body class="import-dialog-box">
  138. <div class="el-upload__text" style="margin:0 0 20px 58px;">提示:导入后的数据将覆盖原有数据</div>
  139. <el-upload
  140. class="import-dialog-upLoad-box"
  141. :drag="true"
  142. :data="upImportData"
  143. :action="uploadImgUrl"
  144. :show-file-list="false"
  145. :on-success="handleAvatarSuccess"
  146. :headers="headers"
  147. :before-upload="beforeAvatarUpload">
  148. <i class="el-icon-upload"></i>
  149. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  150. <!--<div class="el-upload__tip" slot="tip">-->
  151. <!--<el-checkbox v-model="upImportData.upDate">是否更新已经存在的数据</el-checkbox>-->
  152. <!--</div>-->
  153. <div class="el-upload__tip" slot="tip">数据导入模板.xlsx<span style="color:#0183FA;cursor: pointer" @click="importTemplate">下载</span></div>
  154. <div class="el-upload-text-box" slot="tip" v-if="getImportData.downFile">
  155. <div class="img-text-box">
  156. <img src="@/assets/ZDimages/personnelManagement/icon_dr_wj.png">
  157. <p>{{getImportData.textName}}</p>
  158. </div>
  159. <p class="text-p">数据导入成功 <span style="color:#0183FA;">{{getImportData.successNum}}</span> 条,失败 <span style="color:#FF6464 ;">{{getImportData.failureNum}}</span> 条</p>
  160. <div class="img-text-box">
  161. <img src="@/assets/ZDimages/personnelManagement/icon_dr_sj.png">
  162. <p style="color:#0183FA;cursor: pointer;" @click="failureExcel">点击下载失败数据报表</p>
  163. </div>
  164. </div>
  165. </el-upload>
  166. <div slot="footer" class="teacher-import-dialog-button-box">
  167. <p class="inquire-button-one" @click="importOpenOff">确定</p>
  168. </div>
  169. <div class="teacher-import-dialog-position-box" v-if="loading"></div>
  170. </el-dialog>
  171. </div>
  172. </template>
  173. <script>
  174. import { hxpChemicalList,classifyList,getHxpChemicalInfo,delHxpChemicalInfo } from "@/api/medicUniversity-3_1/index";
  175. import { getToken } from "@/utils/auth";
  176. import addPage from "./addPage.vue"
  177. import listPage from "./listPage.vue"
  178. import msdsPage from "./msdsPage.vue"
  179. export default {
  180. name: "ChemicalInfo",
  181. components: {
  182. addPage,
  183. listPage,
  184. msdsPage
  185. },
  186. data() {
  187. return {
  188. // table操作按钮校验
  189. tableButtonType:this.hasPermiDom(['chemical:hxpChemical:query','chemical:hxpChemical:edit','chemical:hxpChemical:remove','chemical:hxpChemical:joinList','chemical:hxpChemical:msdsList']),
  190. //上传相关配置
  191. uploadImgUrl: window.location.href.split('://')[0]+'://' + this.judgmentNetworkReturnAddress() + "/chemical/hxpChemical/importData", // 上传地址
  192. headers: {
  193. Authorization: "Bearer " + getToken(),
  194. },
  195. // 遮罩层
  196. loading:false,
  197. //页面状态
  198. pageType:1,
  199. // 搜索数据
  200. queryParamsData:{
  201. pageNum:1,
  202. pageSize:20,
  203. },
  204. // 搜索实际发送数据
  205. queryParams:{
  206. pageNum:1,
  207. pageSize:20,
  208. },
  209. //数据数量
  210. total:0,
  211. //数据数组
  212. tableList:[],
  213. //表格扩展选择器---需要在@selection-change绑定的方法内监控selection数组长度
  214. selectedNum:0,
  215. // 选中数组
  216. ids: [],
  217. // 非单个禁用
  218. single: true,
  219. // 非多个禁用
  220. multiple: true,
  221. //化学品分类列表
  222. optionsListOne:[],
  223. //属性列表
  224. optionsListTwo:[],
  225. //学院列表
  226. optionsList:[{id:'1', name:"RFID",}, {id:'2', name:"二维码",}],
  227. //导入弹层开关
  228. importOpen:false,
  229. //导入数据
  230. upImportData:{
  231. sysUserEnable:true,
  232. upDate:false,
  233. },
  234. getImportData:{
  235. downFile:false,
  236. successNum:0,
  237. failureNum:0,
  238. textName:"",
  239. },
  240. //新增页面传参
  241. addPropsData:{},
  242. //MSDS页面传参
  243. msdsPropsData:{},
  244. //化学品存放页面传参
  245. listPropsData:{},
  246. };
  247. },
  248. created() {
  249. },
  250. mounted(){
  251. this.getDicts("hxp_classifyattribute").then(response => {
  252. this.optionsListTwo = response.data;
  253. })
  254. this.classifyList();
  255. this.getList();
  256. },
  257. methods: {
  258. //获取化学品分类列表
  259. classifyList(){
  260. classifyList().then(response => {
  261. this.optionsListOne = response.rows;
  262. });
  263. },
  264. //操作按钮
  265. pageToggle(type,item){
  266. if(type == 1){
  267. this.pageType = 1;
  268. if(item == 'refresh'){
  269. this.resetQuery();
  270. }else if(item == 'get'){
  271. this.getList();
  272. }
  273. }else if(type == 2){
  274. //新增
  275. this.$set(this,'addPropsData',{});
  276. this.pageType = 2;
  277. }else if(type == 3){
  278. //关联化学品柜
  279. console.log("item.id",item.id)
  280. this.listPropsData.id = item.id;
  281. this.listPropsData.chemicalName = item.chemicalName;
  282. this.listPropsData.chemicalUnit = item.chemicalUnit;
  283. this.pageType = 3;
  284. }else if(type == 4){
  285. //MSDS
  286. this.msdsPropsData.id = item.id;
  287. this.pageType = 4;
  288. }
  289. this.handleSelectionChangeDel();
  290. },
  291. moreClick(data){
  292. let self = this;
  293. if(data.command == 1){
  294. //编辑
  295. getHxpChemicalInfo(data.row.id).then(response => {
  296. this.addPropsData = response.data;
  297. this.pageType = 2;
  298. });
  299. }else if(data.command == 2){
  300. // this.msgError('该化学试剂有存放库存,无法删除,请先操作出库.');
  301. this.$confirm('确认要删除化学试剂信息吗?', "警告", {
  302. confirmButtonText: "确定",
  303. cancelButtonText: "取消",
  304. type: "warning"
  305. }).then(function() {
  306. delHxpChemicalInfo(data.row.id).then(response => {
  307. if(response.code == 200){
  308. self.msgSuccess(response.msg)
  309. self.pageToggle(1,'get');
  310. }
  311. });
  312. }).then(() => {
  313. }).catch(() => {});
  314. }
  315. },
  316. //获取数据列表
  317. getList(){
  318. this.queryParamsData = JSON.parse(JSON.stringify(this.queryParams));
  319. hxpChemicalList(this.queryParamsData).then(response => {
  320. this.tableList = response.rows;
  321. this.total = response.total
  322. });
  323. },
  324. /** 搜索按钮操作 */
  325. handleQuery() {
  326. this.queryParamsData.pageNum = 1;
  327. this.queryParamsData.pageSize = 20;
  328. this.queryParams = JSON.parse(JSON.stringify(this.queryParamsData));
  329. this.getList();
  330. },
  331. /** 重置按钮操作 */
  332. resetQuery() {
  333. this.$set(this,'queryParamsData',{});
  334. this.$set(this,'queryParams',{});
  335. this.handleQuery();
  336. },
  337. //导入页面关闭
  338. importOpenOff(){
  339. this.importOpen = false;
  340. this.getImportData.downFile = false;
  341. this.getImportData.successNum = 0;
  342. this.getImportData.failureNum = 0;
  343. this.getImportData.textName = "";
  344. },
  345. /** 导入按钮操作 */
  346. importButton(item){
  347. if(item.command == 1){
  348. // 下载模板
  349. this.download('/chemical/hxpChemical/importTemplate', {}, `导入模板.xlsx`)
  350. }else if(item.command == 2){
  351. // 导入数据
  352. console.log('导入数据');
  353. this.importOpen = true;
  354. }
  355. },
  356. /** 当前时间 */
  357. getCurrentTime () {
  358. const yy = new Date().getFullYear()
  359. const mm = new Date().getMonth() + 1
  360. const dd = new Date().getDate()
  361. const hh = new Date().getHours()
  362. const mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
  363. const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
  364. return yy + '-' + mm + '-' + dd
  365. },
  366. /** 导出按钮操作 */
  367. exportButton(item) {
  368. let self = this;
  369. let currentDate = this.getCurrentTime()
  370. if(item.command == 1){
  371. self.$confirm(`确认导出全部数据?`, "提示", {
  372. confirmButtonText: "确定",
  373. cancelButtonText: "取消",
  374. type: "warning"
  375. }).then(async () => {
  376. self.download('/chemical/hxpChemical/export/', {...self.queryParamsData}, '化学品信息-'+currentDate+'.xlsx')
  377. }).catch(() => {})
  378. }else if(item.command == 2){
  379. if(self.ids.length>0) {
  380. self.$confirm(`确认导出选中数据?`, "提示", {
  381. confirmButtonText: "确定",
  382. cancelButtonText: "取消",
  383. type: "warning"
  384. }).then(async () => {
  385. let ids = self.ids.join(',');
  386. let obj = {
  387. ids :ids
  388. }
  389. console.log("obj",obj)
  390. self.download(`/chemical/hxpChemical/export/`,obj, '化学品信息-'+currentDate+'.xlsx')
  391. }).catch(() => {})
  392. }else {
  393. this.msgError('请选择要导出的数据')
  394. }
  395. }
  396. },
  397. /** 下载模板操作 */
  398. importTemplate() {
  399. this.download('/chemical/hxpChemical/importTemplate', {}, `导入模板.xlsx`)
  400. },
  401. /*下载失败列表*/
  402. failureExcel(){
  403. this.download('/chemical/hxpChemical/importErrorData', {}, `失败报表.xlsx`)
  404. }
  405. ,//****************************************导入功能**************************************
  406. handleAvatarSuccess(res, file) {
  407. if(res.code == 200){
  408. if(res.data.downFile){
  409. this.getImportData.downFile = res.data.downFile;
  410. this.getImportData.successNum = res.data.successNum;
  411. this.getImportData.failureNum = res.data.failureNum;
  412. }else{
  413. this.msgSuccess(res.msg);
  414. this.importOpen = false;
  415. this.resetQuery();
  416. }
  417. }else{
  418. this.msgError(res.msg);
  419. }
  420. this.loading = false;
  421. },
  422. beforeAvatarUpload(file) {
  423. let type = false;
  424. console.log('file',file);
  425. if (file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.type == 'application/vnd.ms-excel') {
  426. this.getImportData.textName = file.name;
  427. type = true;
  428. this.loading = true;
  429. }else{
  430. this.msgError('只能上传xls/xlsx格式文件')
  431. type = false;
  432. }
  433. return type;
  434. },
  435. // 多选框选中数据
  436. handleSelectionChange(selection) {
  437. this.selectedNum = selection.length;
  438. this.ids = selection.map(item => item.id);
  439. this.single = selection.length != 1;
  440. this.multiple = !selection.length;
  441. },
  442. handleSelectionChangeDel(){
  443. this.selectedNum = 0;
  444. this.ids = [];
  445. this.single = true;
  446. this.multiple = true;
  447. },
  448. /*===记录勾选数据===
  449. 需要再el-table 添加 :row-key="getRowKeys"
  450. 需要在selection 添加 :reserve-selection="true"
  451. */
  452. getRowKeys(row) {
  453. return row.id
  454. },
  455. }
  456. }
  457. </script>
  458. <style scoped lang="scss">
  459. .ChemicalInfo{
  460. flex:1;
  461. display: flex;
  462. flex-direction: column;
  463. overflow: hidden!important;
  464. p{
  465. margin:0;
  466. padding:0;
  467. }
  468. .ChemicalInfo-page{
  469. flex:1;
  470. display: flex;
  471. flex-direction: column;
  472. overflow: hidden;
  473. padding:20px;
  474. .form-box{
  475. .form-dropdown-box{
  476. display: flex;
  477. margin:0;
  478. padding:0 10px;
  479. cursor: pointer;
  480. height:40px;
  481. img:nth-child(1){
  482. width:16px;
  483. height:16px;
  484. margin-top:12px;
  485. }
  486. p{
  487. width:47px;
  488. text-align: center;
  489. font-size:14px;
  490. margin:0;
  491. line-height:40px;
  492. }
  493. img:nth-child(3){
  494. width:10px;
  495. height:6px;
  496. margin-top:17px;
  497. }
  498. }
  499. }
  500. .button-box{
  501. display: flex;
  502. }
  503. }
  504. }
  505. </style>
  506. <style lang="scss">
  507. .import-dialog-box{
  508. .import-dialog-upLoad-box{
  509. .el-upload{
  510. width:450px;
  511. margin:0 55px;
  512. .el-upload-dragger{
  513. width:450px;
  514. .el-icon-upload{
  515. font-size:100px;
  516. color:#CBE6FE;
  517. }
  518. .el-upload__text{
  519. margin-top:20px;
  520. }
  521. }
  522. }
  523. .el-upload__tip{
  524. margin-left:60px;
  525. font-size:14px;
  526. margin-top:10px;
  527. }
  528. .el-upload-text-box{
  529. background: #F5F5F5;
  530. border-radius: 10px;
  531. margin:15px 30px 0;
  532. padding:0 20px 15px;
  533. overflow: hidden;
  534. *{
  535. margin:0;
  536. }
  537. .img-text-box{
  538. display: flex;
  539. margin-top:15px;
  540. img{
  541. width:16px;
  542. height:16px;
  543. margin-right:13px;
  544. }
  545. p{
  546. height:16px;
  547. line-height:16px;
  548. font-size:12px;
  549. }
  550. }
  551. .text-p{
  552. margin-top:15px;
  553. margin-left:29px;
  554. height:16px;
  555. line-height:16px;
  556. font-size:12px;
  557. }
  558. }
  559. }
  560. .teacher-import-dialog-button-box{
  561. display: flex;
  562. width:190px;
  563. margin:0 auto;
  564. p{
  565. width:70px;
  566. height:30px;
  567. line-height:30px;
  568. font-size:14px;
  569. margin:0 auto;
  570. }
  571. }
  572. .teacher-import-dialog-position-box{
  573. width:100%;
  574. height:100%;
  575. position: absolute;
  576. top:0;
  577. left:0;
  578. z-index: 999;
  579. background: rgba(255,255,255,0.4);
  580. border-radius:20px;
  581. }
  582. }
  583. </style>