listPage.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <!--申购-->
  2. <template>
  3. <div class="listPage">
  4. <div class="listPage-min" v-show="pageType == 1">
  5. <el-form :model="queryParamsData" class="form-box" ref="queryForm" :inline="true">
  6. <el-form-item label="关键字" prop="searchValue">
  7. <el-input
  8. style="width:210px;"
  9. maxLength="30"
  10. v-model="queryParamsData.searchValue"
  11. placeholder="化学品名/别名/CAS号"
  12. clearable
  13. size="small"
  14. />
  15. </el-form-item>
  16. <el-form-item label="化学品分类" prop="chemicalClassify">
  17. <el-select v-model="queryParamsData.chemicalClassify" clearable placeholder="请选择化学品分类" style="width:180px;">
  18. <el-option
  19. v-for="item in optionsListOne"
  20. :key="item.id"
  21. :label="item.classifyName"
  22. :value="item.id">
  23. </el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item label="属性" prop="classifyAttribute">
  27. <el-select v-model="queryParamsData.classifyAttribute" clearable placeholder="请选择属性" style="width:180px;">
  28. <el-option
  29. v-for="item in optionsListTwo"
  30. :key="item.dictValue"
  31. :label="item.dictLabel"
  32. :value="item.dictValue">
  33. </el-option>
  34. </el-select>
  35. </el-form-item>
  36. <el-form-item>
  37. <p class="inquire-button-one" @click="handleQuery" style="margin-right:10px;">查询</p>
  38. <p class="reset-button-one" @click="resetQuery">重置</p>
  39. </el-form-item>
  40. <el-form-item style="float: right;">
  41. <el-col :span="1.5">
  42. <p class="inquire-button-one"
  43. @click="goPage(2)"
  44. >确定</p>
  45. </el-col>
  46. </el-form-item>
  47. <el-form-item style="float: right;">
  48. <el-col :span="1.5">
  49. <p class="reset-button-one"
  50. @click="backPage(0)"
  51. >返回</p>
  52. </el-col>
  53. </el-form-item>
  54. </el-form>
  55. <!--<el-table border :data="tableList" ref="multipleTable" @selection-change="handleSelectionChange" :row-key="getRowKeys">-->
  56. <el-table border :data="tableList" ref="multipleTable" @select-all="handleSelectionChange" @select="handleSelectionChange" :row-key="getRowKeys">
  57. <el-table-column type="selection" width="50" align="center" :reserve-selection="true"/>
  58. <el-table-column label="ID" align="center" prop="chemicalNum" show-overflow-tooltip/>
  59. <el-table-column label="化学品名" align="center" prop="chemicalName" show-overflow-tooltip/>
  60. <el-table-column label="CAS号" align="center" prop="casNum" show-overflow-tooltip/>
  61. <el-table-column label="分类" align="center" prop="classifyName" show-overflow-tooltip/>
  62. <el-table-column label="属性" align="center" prop="classifyAttribute" show-overflow-tooltip/>
  63. <el-table-column label="形态" align="center" prop="chemicalShapeInfo" show-overflow-tooltip/>
  64. <el-table-column label="纯度" align="center" prop="purity" show-overflow-tooltip/>
  65. </el-table>
  66. <pagination
  67. v-show="total>0"
  68. :total="total"
  69. :page-sizes="[20, 30, 40, 50]"
  70. :page.sync="queryParams.pageNum"
  71. :limit.sync="queryParams.pageSize"
  72. @pagination="getList"
  73. />
  74. </div>
  75. <add-page :addPagePropsData="addPagePropsData"
  76. :multipleTableList="multipleTableList"
  77. :editPropsData="editPropsData"
  78. v-if="pageType == 2"></add-page>
  79. </div>
  80. </template>
  81. <script>
  82. import { hxpChemicalList,classifyList } from "@/api/medicUniversity-3_1/index";
  83. import addPage from "./addPage.vue"
  84. export default {
  85. name: "listPage",
  86. components: {
  87. addPage,
  88. },
  89. data(){
  90. return{
  91. tableMsgErrorType:false,
  92. // 遮罩层
  93. loading:false,
  94. //页面状态
  95. pageType:1,
  96. // 分类
  97. optionsListOne:[],
  98. // 属性
  99. optionsListTwo:[],
  100. // 创建时间
  101. dateRange:[],
  102. // 搜索数据
  103. queryParamsData:{
  104. pageNum:1,
  105. pageSize:20,
  106. },
  107. // 搜索实际发送数据
  108. queryParams:{
  109. pageNum:1,
  110. pageSize:20,
  111. },
  112. //数据数量
  113. total:0,
  114. //数据数组
  115. tableList:[],
  116. // 选中用户组
  117. userIds: [],
  118. // 非多个禁用
  119. multiple: true,
  120. //表格扩展选择器---需要在@selection-change绑定的方法内监控selection数组长度
  121. selectedNum:0,
  122. //新增页参数
  123. addPagePropsData:{},
  124. //勾选数据
  125. multipleTableList:[],
  126. //编辑参数
  127. editPropsData:{},
  128. }
  129. },
  130. created() {
  131. },
  132. mounted(){
  133. this.getDicts("hxp_classifyattribute").then(response => {
  134. this.optionsListTwo = response.data;
  135. })
  136. this.classifyList();
  137. this.getList();
  138. },
  139. methods: {
  140. //确定申购
  141. goPage(type,data){
  142. let self = this;
  143. if(type==1){
  144. this.pageType = 1;
  145. this.$set(this,'addPagePropsData',{});
  146. this.$set(this,'multipleTableList',[]);
  147. this.$refs.multipleTable.clearSelection()
  148. }else if(type == 2){
  149. if(!this.multipleTableList[0]){
  150. this.msgError("请勾选化学品")
  151. return
  152. }
  153. this.pageType = 2;
  154. }else if(type == 3){
  155. console.log('data',data);
  156. this.$set(this,'addPagePropsData',JSON.parse(JSON.stringify(data)));
  157. this.pageType = 1;
  158. }
  159. },
  160. //获取数据列表
  161. getList(){
  162. this.queryParamsData = JSON.parse(JSON.stringify(this.queryParams));
  163. hxpChemicalList(this.queryParamsData).then(response => {
  164. this.total = response.total;
  165. this.tableList = response.rows;
  166. });
  167. },
  168. //获取化学品分类列表
  169. classifyList(){
  170. classifyList().then(response => {
  171. this.optionsListOne = response.rows;
  172. });
  173. },
  174. /** 搜索按钮操作 */
  175. handleQuery() {
  176. this.queryParamsData.pageNum = 1;
  177. this.queryParamsData.pageSize = 20;
  178. this.queryParams = JSON.parse(JSON.stringify(this.queryParamsData));
  179. this.getList();
  180. },
  181. /** 重置按钮操作 */
  182. resetQuery() {
  183. this.$set(this,'queryParamsData',{});
  184. this.$set(this,'queryParams',{});
  185. this.handleQuery();
  186. },
  187. //返回
  188. backPage(type){
  189. if(type == 0){
  190. this.$parent.pageToggle(0);
  191. }else if(type == 1){
  192. this.$parent.pageToggle(1);
  193. }
  194. },
  195. // 多选框选中数据
  196. handleSelectionChange(selection) {
  197. let self = this;
  198. this.$refs.multipleTable.clearSelection();
  199. let list = [];
  200. for(let i=0;i<selection.length;i++){
  201. if(i>19){
  202. self.$refs.multipleTable.toggleRowSelection(selection[i],false);
  203. }else{
  204. list.push(selection[i])
  205. self.$refs.multipleTable.toggleRowSelection(selection[i],true);
  206. }
  207. }
  208. this.$set(this,'multipleTableList',list);
  209. if (selection.length>20){
  210. this.msgError("一次最多可申购20个化学品")
  211. }
  212. // let list = JSON.parse(JSON.stringify(this.multipleTableList))
  213. // for(let i=0;i<selection.length;i++){
  214. // let num = 0;
  215. // for(let o=0;o<list.length;o++){
  216. // if(selection[i].id == list[o].id){
  217. // num++
  218. // }
  219. // }
  220. // if(num == 0){
  221. // list.push(selection[i])
  222. // }
  223. // }
  224. // if(list.length<=20){
  225. // this.selectedNum = selection.length;
  226. // this.userIds = selection.map(item => item.id)
  227. // this.$set(this,'multipleTableList',selection);
  228. // this.multiple = !selection.length
  229. // }else{
  230. // this.$refs.multipleTable.clearSelection();
  231. // setTimeout(function(){
  232. // for(let i=0;i<20;i++){
  233. // self.$refs.multipleTable.toggleRowSelection(self.multipleTableList[i],true);
  234. // }
  235. // },50);
  236. // this.msgError("一次最多可申购20个化学品")
  237. // }
  238. },
  239. /*===记录勾选数据===
  240. 需要再el-table 添加 :row-key="getRowKeys"
  241. 需要在selection 添加 :reserve-selection="true"
  242. */
  243. getRowKeys(row) {
  244. return row.id
  245. },
  246. }
  247. }
  248. </script>
  249. <style scoped lang="scss">
  250. .listPage{
  251. flex:1;
  252. display: flex;
  253. flex-direction: column;
  254. overflow: hidden;
  255. p{
  256. margin:0;
  257. padding:0;
  258. }
  259. .listPage-min{
  260. flex:1;
  261. display: flex;
  262. flex-direction: column;
  263. overflow: hidden;
  264. padding:20px;
  265. .button-box{
  266. display: flex;
  267. }
  268. }
  269. }
  270. </style>