msdsPage.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <div class="msdsPage">
  3. <div class="msds-page" v-if="!lookOpen">
  4. <div class="title-box">
  5. <p>MSDS化学品安全技术说明书</p>
  6. <p class="reset-button-one" @click="backPage"><i class="el-icon-arrow-left"></i>返回</p>
  7. </div>
  8. <div class="msdsPage-min">
  9. <el-form :model="queryParamsData" class="form-box" ref="queryForm" :inline="true">
  10. <el-form-item label="关键字" prop="name">
  11. <el-input
  12. maxLength="20"
  13. v-model="queryParamsData.name"
  14. placeholder="危险品名称"
  15. clearable
  16. size="small"
  17. style="width: 200px"
  18. />
  19. </el-form-item>
  20. <el-form-item>
  21. <p class="inquire-button-one" @click="handleQuery" style="margin-right:10px;">查询</p>
  22. <p class="reset-button-one" @click="resetQuery">重置</p>
  23. </el-form-item>
  24. <el-form-item style="float: right;">
  25. <el-col :span="1.5">
  26. <p class="add-button-one-90"
  27. @click="upData"
  28. >确定</p>
  29. </el-col>
  30. </el-form-item>
  31. </el-form>
  32. <el-table border :data="tableList" ref="multipleTable" :row-key="getRowKeys"
  33. tooltip-effect="dark" @select-all="dialogCheck" @select="dialogCheck">
  34. <el-table-column type="selection" width="50" align="center" :reserve-selection="true"/>
  35. <el-table-column label="序号" type="index" align="center" width="50"/>
  36. <el-table-column label="化学品名称" align="center" prop="name"/>
  37. <el-table-column label="编号" align="center" prop="code"/>
  38. <el-table-column label="创建时间" align="center" prop="createTime"/>
  39. <el-table-column label="创建人" align="center" prop="createBy"/>
  40. <el-table-column label="操作" align="center" width="140" class-name="small-padding fixed-width">
  41. <template slot-scope="scope">
  42. <div class="table-button-box">
  43. <p class="table-button-null"></p>
  44. <p class="table-button-p" @click="lookItem(true,scope.row)">查看</p>
  45. <p class="table-button-null"></p>
  46. </div>
  47. </template>
  48. </el-table-column>
  49. </el-table>
  50. <div style="display: flex;height:32px;margin:5px 0 15px;">
  51. <!--<p style="flex:4;"></p>-->
  52. <p style="text-align: left;margin:0;line-height:32px;margin-top:15px;margin-right:20px;font-size:14px;color:#999;">
  53. <i class="el-icon-warning" style="color:#0183FA;"></i>
  54. 已选择 {{selectioned.id?"1":"0"}} 项
  55. </p>
  56. <div style="flex:5;">
  57. <pagination :page-sizes="[20, 30, 40, 50]"
  58. v-show="total>0"
  59. :total="total"
  60. style="margin:0;"
  61. :page.sync="queryParams.pageNum"
  62. :limit.sync="queryParams.pageSize"
  63. @pagination="getList"
  64. />
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. <!--查看窗口-->
  70. <msds-info v-if="lookOpen" :dialogData="dialogData"></msds-info>
  71. <!--<el-dialog :title="dialogTitle" :visible.sync="lookOpen" width="1200px" append-to-body class="w-e-text-dialog-box">-->
  72. <!--<div style="width:1160px;max-height:700px;overflow-y: scroll;" class="scrollbar-box">-->
  73. <!--<div class="w-e-text-min-box">-->
  74. <!--<p>化学品名称:</p>-->
  75. <!--<p>{{dialogData.name}}</p>-->
  76. <!--</div>-->
  77. <!--<div class="w-e-text-min-box">-->
  78. <!--<p>说明书编号:</p>-->
  79. <!--<p>{{dialogData.code}}</p>-->
  80. <!--</div>-->
  81. <!--<div class="w-e-text-min-box-one">-->
  82. <!--<p>说明书详情:</p>-->
  83. <!--<p class="w-e-text" v-html="dialogData.content"></p>-->
  84. <!--</div>-->
  85. <!--</div>-->
  86. <!--<div slot="footer" class="teacher-import-dialog-button-box">-->
  87. <!--<p class="inquire-button-one" @click="lookItem(false)">确定</p>-->
  88. <!--</div>-->
  89. <!--</el-dialog>-->
  90. </div>
  91. </template>
  92. <script>
  93. import { getHazard_book } from "@/api/laboratory/hazard_book";
  94. import { getHazardBookJoinChemical,editChemicalByJoinHazard } from "@/api/medicUniversity-3_1/index";
  95. import msdsInfo from "./msdsInfo.vue"
  96. export default {
  97. name: "msdsPage",
  98. components: {
  99. msdsInfo
  100. },
  101. props:{
  102. msdsPropsData:{},
  103. },
  104. data() {
  105. return {
  106. // 搜索数据
  107. queryParamsData:{
  108. pageNum:1,
  109. pageSize:20,
  110. },
  111. // 搜索实际发送数据
  112. queryParams:{
  113. pageNum:1,
  114. pageSize:20,
  115. },
  116. //数据数量
  117. total:0,
  118. //数据数组
  119. tableList:[],
  120. //表格扩展选择器---需要在@selection-change绑定的方法内监控selection数组长度
  121. selectedNum:0,
  122. // 选中数组
  123. ids: [],
  124. // 非单个禁用
  125. single: true,
  126. // 非多个禁用
  127. multiple: true,
  128. selectioned:{},
  129. //查看相关
  130. dialogTitle:"",
  131. dialogData:{},
  132. lookOpen:false,
  133. }
  134. },
  135. created() {
  136. },
  137. mounted(){
  138. this.getList();
  139. },
  140. methods:{
  141. //提交
  142. upData(){
  143. let obj = {
  144. id:this.msdsPropsData.id,
  145. }
  146. if(this.selectioned.id){
  147. obj.joinHazardId = this.selectioned.id;
  148. }else{
  149. obj.joinHazardId = "";
  150. }
  151. editChemicalByJoinHazard(obj).then(response => {
  152. if(response.code == 200){
  153. this.msgSuccess(response.msg);
  154. this.$parent.pageToggle(1,'get');
  155. }
  156. });
  157. },
  158. //查看按钮
  159. lookItem(type,row){
  160. if(type){
  161. getHazard_book(row.id).then( response => {
  162. this.dialogData.dialogTitle = row.name + '-安全技术说明书';
  163. this.dialogData.name = response.data.name;
  164. this.dialogData.code = response.data.code;
  165. this.dialogData.content = unescape(response.data.content);
  166. this.lookOpen = true;
  167. });
  168. }else{
  169. this.lookOpen = false;
  170. }
  171. },
  172. getList(){
  173. let self = this;
  174. this.queryParamsData = JSON.parse(JSON.stringify(this.queryParams));
  175. this.queryParamsData.chemicalId = this.msdsPropsData.id;
  176. getHazardBookJoinChemical(this.queryParamsData).then(response => {
  177. this.tableList = response.rows;
  178. this.total = response.total
  179. if(response.rows[0].joinHazardId&&this.queryParamsData.pageNum == 1){
  180. setTimeout(function(){
  181. self.$set(self,"selectioned",response.rows[0]);
  182. self.$refs.multipleTable.toggleRowSelection(response.rows[0], true);
  183. },50);
  184. }else{
  185. self.$set(self,"selectioned",{});
  186. }
  187. });
  188. },
  189. /** 搜索按钮操作 */
  190. handleQuery() {
  191. this.queryParamsData.pageNum = 1;
  192. this.queryParamsData.pageSize = 20;
  193. this.queryParams = JSON.parse(JSON.stringify(this.queryParamsData));
  194. this.getList();
  195. },
  196. /** 重置按钮操作 */
  197. resetQuery() {
  198. this.$set(this,'queryParamsData',{});
  199. this.$set(this,'queryParams',{});
  200. this.handleQuery();
  201. },
  202. dialogCheck (selection, row) {
  203. console.log("selection",selection)
  204. console.log("row",row)
  205. this.$refs.multipleTable.clearSelection()
  206. if (selection.length === 0) {
  207. // 判断selection是否有值存在
  208. this.selectioned = {};
  209. return
  210. }
  211. if (row) {
  212. this.selectioned = row
  213. this.$refs.multipleTable.toggleRowSelection(row, true)
  214. }
  215. },
  216. backPage(){
  217. this.$parent.pageToggle(1);
  218. },
  219. /*===记录勾选数据===
  220. 需要再el-table 添加 :row-key="getRowKeys"
  221. 需要在selection 添加 :reserve-selection="true"
  222. */
  223. getRowKeys(row) {
  224. return row.id
  225. },
  226. }
  227. }
  228. </script>
  229. <style scoped lang="scss">
  230. .msdsPage{
  231. flex:1;
  232. display: flex;
  233. flex-direction: column;
  234. overflow: hidden;
  235. font-weight:500;
  236. p{
  237. margin:0;
  238. padding:0;
  239. }
  240. .msds-page{
  241. flex:1;
  242. display: flex;
  243. flex-direction: column;
  244. overflow: hidden;
  245. .title-box{
  246. display: flex;
  247. height:90px;
  248. border-bottom: 1px solid #D8D8D8;
  249. p:nth-child(1){
  250. flex:1;
  251. font-size:16px;
  252. line-height:90px;
  253. margin-left:18px;
  254. color:#0045AF;
  255. }
  256. p:nth-child(2){
  257. margin:25px 25px 0 0;
  258. }
  259. }
  260. .msdsPage-min{
  261. flex:1;
  262. padding:20px;
  263. display: flex;
  264. flex-direction: column;
  265. overflow: hidden;
  266. }
  267. }
  268. }
  269. </style>