listPage.vue 8.6 KB

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