index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="编号" prop="plantCode">
  5. <el-input
  6. v-model="queryParams.plantCode"
  7. placeholder="请输入编号"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="名称" prop="plantName">
  13. <el-input
  14. v-model="queryParams.plantName"
  15. placeholder="请输入名称"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="类别" prop="plantType">
  21. <el-select v-model="queryParams.plantType" @change="handleQuery" placeholder="请选择类别" clearable size="small"
  22. style="width: 200px">
  23. <el-option
  24. v-for="dict in plantTypeOptions"
  25. :key="dict.dictValue"
  26. :label="dict.dictLabel"
  27. :value="dict.dictValue"
  28. />
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item label="加工/生产能力(t/a)" prop="proAbility" label-width="140px">
  32. <el-input
  33. v-model="queryParams.proAbility"
  34. placeholder="请输入加工/生产能力(t/a)"
  35. clearable
  36. @keyup.enter.native="handleQuery"
  37. />
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  41. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  42. </el-form-item>
  43. </el-form>
  44. <el-row :gutter="10" class="mb8">
  45. <el-col :span="1.5">
  46. <el-button
  47. type="primary"
  48. plain
  49. icon="el-icon-plus"
  50. size="mini"
  51. @click="handleAdd"
  52. v-hasPermi="['base:plant:add']"
  53. >新增
  54. </el-button>
  55. </el-col>
  56. <el-col :span="1.5">
  57. <el-button
  58. type="success"
  59. plain
  60. icon="el-icon-edit"
  61. size="mini"
  62. :disabled="single"
  63. @click="handleUpdate"
  64. v-hasPermi="['base:plant:edit']"
  65. >修改
  66. </el-button>
  67. </el-col>
  68. <el-col :span="1.5">
  69. <el-button
  70. type="danger"
  71. plain
  72. icon="el-icon-delete"
  73. size="mini"
  74. :disabled="multiple"
  75. @click="handleDelete"
  76. v-hasPermi="['base:plant:remove']"
  77. >删除
  78. </el-button>
  79. </el-col>
  80. <el-col :span="1.5">
  81. <el-button
  82. type="warning"
  83. plain
  84. icon="el-icon-download"
  85. size="mini"
  86. @click="handleExport"
  87. v-hasPermi="['base:plant:export']"
  88. >导出
  89. </el-button>
  90. </el-col>
  91. <el-col :span="1.5">
  92. <el-button
  93. type="info"
  94. plain
  95. icon="el-icon-position"
  96. size="mini"
  97. :disabled="multiple"
  98. @click="handleToApprove"
  99. >送审
  100. </el-button>
  101. </el-col>
  102. <el-col :span="1.5">
  103. <el-button
  104. type="info"
  105. plain
  106. icon="el-icon-s-check"
  107. size="mini"
  108. :disabled="multiple"
  109. @click="handleApprove"
  110. >审核
  111. </el-button>
  112. </el-col>
  113. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  114. </el-row>
  115. <el-table v-loading="loading" ref="plantTable" :data="plantList" @selection-change="handleSelectionChange"
  116. :height="clientHeight" border :cell-style="tableCellStyle">
  117. <el-table-column type="selection" width="55" align="center"/>
  118. <el-table-column label="审核状态" align="center" prop="approveStatus"
  119. :formatter="approveStatusFormat"/>
  120. <el-table-column label="编号" align="center" prop="plantCode"/>
  121. <el-table-column label="名称" align="center" prop="plantName"/>
  122. <el-table-column label="加工/生产能力(t/a)" align="center" prop="proAbility"/>
  123. <el-table-column label="类别" align="center" prop="plantType" :formatter="plantTypeFormat"/>
  124. <el-table-column label="最后维护人" align="center" prop="updater"/>
  125. <el-table-column label="维护时间" align="center" prop="updatedate" width="180">
  126. <template slot-scope="scope">
  127. <span>{{ parseTime(scope.row.updatedate, '{y}-{m}-{d}') }}</span>
  128. </template>
  129. </el-table-column>
  130. <el-table-column label="描述" align="center" prop="remarks"/>
  131. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  132. <template slot-scope="scope">
  133. <el-button
  134. size="mini"
  135. type="text"
  136. icon="el-icon-edit"
  137. @click="handleUpdate(scope.row)"
  138. v-hasPermi="['base:plant:edit']"
  139. >修改
  140. </el-button>
  141. <el-button
  142. size="mini"
  143. type="text"
  144. icon="el-icon-delete"
  145. @click="handleDelete(scope.row)"
  146. v-hasPermi="['base:plant:remove']"
  147. >删除
  148. </el-button>
  149. </template>
  150. </el-table-column>
  151. </el-table>
  152. <pagination
  153. v-show="total>0"
  154. :total="total"
  155. :page.sync="queryParams.pageNum"
  156. :limit.sync="queryParams.pageSize"
  157. @pagination="getList"
  158. />
  159. <!-- 添加或修改装置对话框 -->
  160. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  161. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  162. <el-form-item label="编号" prop="plantCode">
  163. <el-input v-model="form.plantCode" placeholder="请输入编号"/>
  164. </el-form-item>
  165. <el-form-item label="名称" prop="plantName">
  166. <el-input v-model="form.plantName" placeholder="请输入名称"/>
  167. </el-form-item>
  168. <el-form-item label="类别" prop="plantType">
  169. <el-select v-model="form.plantType" placeholder="请选择类别" clearable size="small" style="width: 100%">
  170. <el-option
  171. v-for="dict in plantTypeOptions"
  172. :key="dict.dictValue"
  173. :label="dict.dictLabel"
  174. :value="dict.dictValue"
  175. />
  176. </el-select>
  177. </el-form-item>
  178. <el-form-item label="加工/生产能力" prop="proAbility">
  179. <el-input v-model="form.proAbility" placeholder="请输入加工/生产能力"/>
  180. </el-form-item>
  181. <el-form-item label="描述" prop="remarks">
  182. <el-input v-model="form.remarks" placeholder="请输入描述"/>
  183. </el-form-item>
  184. </el-form>
  185. <div slot="footer" class="dialog-footer">
  186. <el-button type="primary" @click="submitForm">确 定</el-button>
  187. <el-button @click="cancel">取 消</el-button>
  188. </div>
  189. </el-dialog>
  190. </div>
  191. </template>
  192. <script>
  193. import {listPlant, getPlant, delPlant, addPlant, updatePlant, handleApprove} from "@/api/base/plant";
  194. import {MessageBox} from "element-ui";
  195. export default {
  196. name: "Plant",
  197. data() {
  198. return {
  199. plantTypeOptions: [],
  200. approveStatusOperation: [],
  201. clientHeight: 300,
  202. // 遮罩层
  203. loading: true,
  204. // 选中数组
  205. ids: [],
  206. status: [],
  207. // 非单个禁用
  208. single: true,
  209. // 非多个禁用
  210. multiple: true,
  211. // 显示搜索条件
  212. showSearch: false,
  213. // 总条数
  214. total: 0,
  215. // 装置表格数据
  216. plantList: [],
  217. // 弹出层标题
  218. title: "",
  219. // 是否显示弹出层
  220. open: false,
  221. // 查询参数
  222. queryParams: {
  223. pageNum: 1,
  224. pageSize: 10,
  225. plantCode: null,
  226. plantName: null,
  227. proAbility: null,
  228. plantType: null,
  229. remarks: null,
  230. approveStatus: null,
  231. approveTime: null,
  232. deptId: null,
  233. createrCode: null,
  234. createdate: null,
  235. updaterCode: null,
  236. updatedate: null
  237. },
  238. // 表单参数
  239. form: {},
  240. // 表单校验
  241. rules: {
  242. plantName: [
  243. {required: true, message: this.$t('装置名称') + this.$t('不能为空'), trigger: "blur"}
  244. ],
  245. plantCode: [
  246. {required: true, message: this.$t('装置编号') + this.$t('不能为空'), trigger: "blur"}
  247. ],
  248. plantType: [
  249. {required: true, message: this.$t('装置类别') + this.$t('不能为空'), trigger: "blur"}
  250. ],
  251. }
  252. };
  253. },
  254. watch: {
  255. tableData(val) {
  256. this.doLayout();
  257. }
  258. },
  259. created() {
  260. //设置表格高度对应屏幕高度
  261. this.$nextTick(() => {
  262. this.clientHeight = (document.body.clientHeight - 80) * 0.8
  263. });
  264. this.getDicts("plant_type").then(response => {
  265. this.plantTypeOptions = response.data;
  266. });
  267. this.getDicts("base_approve_status").then(response => {
  268. this.approveStatusOperation = response.data;
  269. });
  270. this.getList();
  271. },
  272. methods: {
  273. tableCellStyle({row, column, rowIndex, columnIndex}) {
  274. if (columnIndex === 1 && row.approveStatus == 2) {
  275. return "color:#13C2C2;";
  276. }
  277. if (columnIndex === 1 && row.approveStatus == 1) {
  278. return "color:#0000FF;";
  279. }
  280. if (columnIndex === 1 && row.approveStatus == 0) {
  281. return "color:#ff0000;";
  282. }
  283. },
  284. /* 重新渲染table组件 */
  285. doLayout(){
  286. this.$nextTick(() => {
  287. this.$refs.plantTable.doLayout()
  288. })
  289. },
  290. plantTypeFormat(row, column) {
  291. return this.selectDictLabel(this.plantTypeOptions, row.plantType);
  292. },
  293. approveStatusFormat(row, column) {
  294. return this.selectDictLabel(this.approveStatusOperation, row.approveStatus);
  295. },
  296. /** 查询装置列表 */
  297. getList() {
  298. this.loading = true;
  299. listPlant(this.queryParams).then(response => {
  300. this.plantList = response.rows;
  301. this.total = response.total;
  302. this.$nextTick(() => {
  303. this.$refs.plantTable.doLayout(); // 解决表格错位
  304. });
  305. this.loading = false;
  306. });
  307. },
  308. // 取消按钮
  309. cancel() {
  310. this.open = false;
  311. this.reset();
  312. },
  313. // 表单重置
  314. reset() {
  315. this.form = {
  316. plantId: null,
  317. plantCode: null,
  318. plantName: null,
  319. proAbility: null,
  320. plantType: null,
  321. remarks: null,
  322. approveStatus: 0,
  323. approveTime: null,
  324. deptId: null,
  325. delFlag: null,
  326. createrCode: null,
  327. createdate: null,
  328. updaterCode: null,
  329. updatedate: null
  330. };
  331. this.resetForm("form");
  332. },
  333. /** 搜索按钮操作 */
  334. handleQuery() {
  335. this.queryParams.pageNum = 1;
  336. this.getList();
  337. },
  338. /** 重置按钮操作 */
  339. resetQuery() {
  340. this.resetForm("queryForm");
  341. this.handleQuery();
  342. },
  343. // 多选框选中数据
  344. handleSelectionChange(selection) {
  345. this.ids = selection.map(item => item.plantId)
  346. this.status = selection.map(item => item.approveStatus)
  347. this.single = selection.length !== 1
  348. this.multiple = !selection.length
  349. },
  350. /** 新增按钮操作 */
  351. handleAdd() {
  352. this.reset();
  353. this.open = true;
  354. this.title = "添加装置";
  355. },
  356. /** 修改按钮操作 */
  357. handleUpdate(row) {
  358. this.reset();
  359. if (row.approveStatus!=0){
  360. MessageBox.alert('已送审/已审核的数据不可修改!', '注意!', {
  361. confirmButtonText: '确定',
  362. })
  363. return;
  364. }
  365. const plantId = row.plantId || this.ids
  366. getPlant(plantId).then(response => {
  367. this.form = response.data;
  368. this.open = true;
  369. this.title = "修改装置";
  370. });
  371. },
  372. /** 提交按钮 */
  373. submitForm() {
  374. this.$refs["form"].validate(valid => {
  375. if (valid) {
  376. if (this.form.plantId != null) {
  377. updatePlant(this.form).then(response => {
  378. this.$modal.msgSuccess("修改成功");
  379. this.open = false;
  380. this.getList();
  381. });
  382. } else {
  383. addPlant(this.form).then(response => {
  384. this.$modal.msgSuccess(response.msg);
  385. this.open = false;
  386. this.getList();
  387. });
  388. }
  389. }
  390. });
  391. },
  392. /** 删除按钮操作 */
  393. handleDelete(row) {
  394. const ids = row.plantId || this.ids;
  395. if(row.approveStatus===undefined){
  396. for (let i = 0; i < this.status.length; i++) {
  397. if (this.status[i] != 0) {
  398. MessageBox.alert('已送审/已审核的数据不可删除!', '注意!', {
  399. confirmButtonText: '确定',
  400. })
  401. return
  402. }
  403. }
  404. }else if (row.approveStatus!=0){
  405. MessageBox.alert('已送审/已审核的数据不可删除!', '注意!', {
  406. confirmButtonText: '确定',
  407. })
  408. return
  409. }
  410. this.$modal.confirm('是否确认删除数据项?').then(function () {
  411. return delPlant(ids);
  412. }).then(() => {
  413. this.getList();
  414. this.$modal.msgSuccess("删除成功");
  415. }).catch(() => {
  416. });
  417. },
  418. /** 导出按钮操作 */
  419. handleExport() {
  420. this.download('base/plant/export', {
  421. ...this.queryParams
  422. }, `plant_${new Date().getTime()}.xlsx`)
  423. },
  424. handleToApprove() {
  425. let data={};
  426. data.plantIds=this.ids;
  427. data.approveStatus=1;
  428. handleApprove(data).then(()=>{
  429. this.getList();
  430. })
  431. },handleApprove() {
  432. let data={};
  433. data.plantIds=this.ids;
  434. data.approveStatus=2;
  435. handleApprove(data).then(()=>{
  436. this.getList();
  437. })
  438. }
  439. }
  440. };
  441. </script>