index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="企业名称" prop="enterpriseName">
  5. <el-input
  6. v-model="queryParams.enterpriseName"
  7. placeholder="请输入企业名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="燃气成份" prop="component">
  14. <el-input
  15. v-model="queryParams.component"
  16. placeholder="请输入燃气成份"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="运输车辆车牌号" prop="carNumber" label-width="110px">
  23. <el-input
  24. v-model="queryParams.carNumber"
  25. placeholder="请输入运输车辆车牌号"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  33. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  34. </el-form-item>
  35. </el-form>
  36. <el-row :gutter="10" class="mb8">
  37. <el-col :span="1.5">
  38. <el-button
  39. type="primary"
  40. plain
  41. icon="el-icon-plus"
  42. size="mini"
  43. @click="handleAdd"
  44. v-hasPermi="['housingconstruction:gassource:add']"
  45. >新增
  46. </el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button
  50. type="success"
  51. plain
  52. icon="el-icon-edit"
  53. size="mini"
  54. :disabled="single"
  55. @click="handleUpdate"
  56. v-hasPermi="['housingconstruction:gassource:edit']"
  57. >修改
  58. </el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="danger"
  63. plain
  64. icon="el-icon-delete"
  65. size="mini"
  66. :disabled="multiple"
  67. @click="handleDelete"
  68. v-hasPermi="['housingconstruction:gassource:remove']"
  69. >删除
  70. </el-button>
  71. </el-col>
  72. <el-col :span="1.5">
  73. <el-button
  74. type="warning"
  75. plain
  76. icon="el-icon-download"
  77. size="mini"
  78. @click="handleExport"
  79. v-hasPermi="['housingconstruction:gassource:export']"
  80. >导出
  81. </el-button>
  82. </el-col>
  83. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  84. </el-row>
  85. <el-table v-loading="loading" :data="gassourceList" @selection-change="handleSelectionChange">
  86. <el-table-column type="selection" width="55" align="center"/>
  87. <el-table-column label="企业名称" align="center" prop="enterpriseName"/>
  88. <el-table-column label="来源企业" align="center" prop="sourceEnterpriseName"/>
  89. <el-table-column label="来源地" align="center" prop="address"/>
  90. <el-table-column label="燃气成份" align="center" prop="component"/>
  91. <!-- <el-table-column label="燃气成份" align="center" prop="component">
  92. <template slot-scope="scope">
  93. <dict-tag :options="dict.type.housingconstruction_component" :value="scope.row.component"/>
  94. </template>
  95. </el-table-column>-->
  96. <el-table-column label="入站时间" align="center" prop="joinInstationTime" width="180">
  97. <template slot-scope="scope">
  98. <span>{{ parseTime(scope.row.joinInstationTime, '{y}-{m}-{d}') }}</span>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="运输体积" align="center" prop="weight"/>
  102. <el-table-column label="运输车辆车牌号" align="center" prop="carNumber" />
  103. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  104. <template slot-scope="scope">
  105. <el-button
  106. size="mini"
  107. type="text"
  108. icon="el-icon-edit"
  109. @click="handleUpdate(scope.row)"
  110. v-hasPermi="['housingconstruction:gassource:edit']"
  111. >修改
  112. </el-button>
  113. <el-button
  114. size="mini"
  115. type="text"
  116. icon="el-icon-delete"
  117. @click="handleDelete(scope.row)"
  118. v-hasPermi="['housingconstruction:gassource:remove']"
  119. >删除
  120. </el-button>
  121. </template>
  122. </el-table-column>
  123. </el-table>
  124. <pagination
  125. v-show="total>0"
  126. :total="total"
  127. :page.sync="queryParams.pageNum"
  128. :limit.sync="queryParams.pageSize"
  129. @pagination="getList"
  130. />
  131. <!-- 添加或修改气源数据对话框 -->
  132. <el-dialog :title="title" :visible.sync="open" width="1300px" append-to-body class="form-style">
  133. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  134. <el-row :gutter="24">
  135. <el-col :span="12">
  136. <el-form-item label="所属厂站" prop="enterpriseId">
  137. <el-select v-model="form.enterpriseId" placeholder="请选择所属厂站" @change="handleEnterpriseChange">
  138. <el-option
  139. v-for="data in enterpriseList"
  140. :key="data.id"
  141. :label="data.enterpriseName"
  142. :value="data.id"
  143. ></el-option>
  144. </el-select>
  145. </el-form-item>
  146. </el-col>
  147. <el-col :span="12">
  148. <el-form-item label="来源企业" prop="sourceEnterpriseName">
  149. <el-input v-model="form.sourceEnterpriseName" placeholder="请输入来源企业"/>
  150. </el-form-item>
  151. </el-col>
  152. </el-row>
  153. <el-row :gutter="24">
  154. <el-col :span="12">
  155. <el-form-item label="燃气成份" prop="component">
  156. <el-input v-model="form.component" placeholder="请输入燃气成份"/>
  157. <!-- <el-select v-model="form.component" placeholder="请选择燃气成份">
  158. <el-option
  159. v-for="dict in dict.type.housingconstruction_component"
  160. :key="dict.value"
  161. :label="dict.label"
  162. :value="dict.value"
  163. ></el-option>
  164. </el-select>-->
  165. </el-form-item>
  166. </el-col>
  167. <el-col :span="12">
  168. <el-form-item label="来源地" prop="address">
  169. <el-input v-model="form.address" placeholder="请输入来源地"/>
  170. </el-form-item>
  171. </el-col>
  172. </el-row>
  173. <el-row :gutter="24">
  174. <el-col :span="12">
  175. <el-form-item label="运输车辆" prop="carId">
  176. <el-input v-model="form.carId" placeholder="请输入运输车辆"/>
  177. <!-- <el-select v-model="form.carId" filterable placeholder="请选择运输车辆" @change="handleCarChange">
  178. <el-option
  179. v-for="data in carList"
  180. :key="data.id"
  181. :label="data.carNumber"
  182. :value="data.id"
  183. ></el-option>
  184. </el-select>-->
  185. </el-form-item>
  186. </el-col>
  187. <el-col :span="12">
  188. <el-form-item label="运输体积" prop="weight">
  189. <el-input v-model="form.weight" placeholder="请输入运输体积"/>
  190. </el-form-item>
  191. </el-col>
  192. </el-row>
  193. <el-row :gutter="24">
  194. <el-col :span="12">
  195. <el-col :span="12">
  196. <el-form-item label="入站时间" prop="joinInstationTime">
  197. <el-date-picker clearable size="small"
  198. v-model="form.joinInstationTime"
  199. type="date"
  200. value-format="yyyy-MM-dd"
  201. placeholder="选择入站时间">
  202. </el-date-picker>
  203. </el-form-item>
  204. </el-col>
  205. </el-col>
  206. <el-col :span="12">
  207. <el-form-item label="所属部门" prop="deptId">
  208. <treeselect v-model="form.deptId" :options="deptOptions" multiple:false :show-count="true"
  209. placeholder="请选择部门" @select="hx" :noResultsText="'空'" :noOptionsText="'空'"/>
  210. </el-form-item>
  211. </el-col>
  212. </el-row>
  213. <el-row :gutter="24">
  214. <el-form-item label="危化品检测报告" prop="fileUrl" label-width="130px">
  215. <fileUpload v-model="form.fileUrl" :setFileName="setFileName" :removeFileName="removeFileName"></fileUpload>
  216. </el-form-item>
  217. </el-row>
  218. <el-row :gutter="24">
  219. <el-form-item label="危化品运输车辆许可" prop="attachPaths" label-width="160px">
  220. <ImageUpload v-model="form.attachPaths" ref="ImageUpload" :fileType="['png', 'jpg', 'jpeg']" :value="form.attachPaths" @input="getUrl" :limit="10"></ImageUpload>
  221. </el-form-item>
  222. </el-row>
  223. </el-form>
  224. <div slot="footer" class="dialog-footer">
  225. <el-button type="primary" @click="submitForm">确 定</el-button>
  226. <el-button @click="cancel">取 消</el-button>
  227. </div>
  228. </el-dialog>
  229. </div>
  230. </template>
  231. <script>
  232. import {
  233. addGassource,
  234. delGassource,
  235. getGassource,
  236. listGassource,
  237. updateGassource
  238. } from "@/api/data/housingconstruction/gassource";
  239. import {getListAll} from "@/api/data/housingconstruction/enterprise";
  240. import deptselector from "@/views/components/deptselector.vue";
  241. import Treeselect from "@riophae/vue-treeselect";
  242. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  243. import {treeselect} from "@/api/system/dept";
  244. import {getCarList} from "@/api/data/housingconstruction/car";
  245. import DataImageUpload from "@/components/ImageUpload/dataUpload.vue";
  246. import FileUpload from '@/views/components/FileUpload/index.vue'
  247. import {format_date} from "@/views/data/common/dateExport";
  248. export default {
  249. name: "Gassource",
  250. components: {DataImageUpload, deptselector, Treeselect, FileUpload},
  251. dicts: ['housingconstruction_component'],
  252. data() {
  253. return {
  254. // 遮罩层
  255. loading: true,
  256. // 选中数组
  257. ids: [],
  258. // 非单个禁用
  259. single: true,
  260. // 非多个禁用
  261. multiple: true,
  262. // 显示搜索条件
  263. showSearch: true,
  264. fileNames: [],
  265. // 总条数
  266. total: 0,
  267. // 气源数据表格数据
  268. gassourceList: [],
  269. //企业信息列表
  270. enterpriseList: [],
  271. // 部门树选项
  272. deptOptions: [],
  273. //车辆列表
  274. carList: [],
  275. // 弹出层标题
  276. title: "",
  277. // 是否显示弹出层
  278. open: false,
  279. // 查询参数
  280. queryParams: {
  281. pageNum: 1,
  282. pageSize: 10,
  283. enterpriseName: null,
  284. address: null,
  285. component: null,
  286. joinInstationTime: null,
  287. weight: null,
  288. carNumber: null
  289. },
  290. // 表单参数
  291. form: {
  292. fileUrl: '',
  293. fileName: '',
  294. fileUrlList: [],
  295. fileNameList: []
  296. },
  297. // 表单校验
  298. rules: {
  299. enterpriseId: [
  300. {required: true, message: "企业不能为空", trigger: "blur"}
  301. ],
  302. sourceEnterpriseName: [
  303. {required: true, message: "来源企业不能为空", trigger: "blur"}
  304. ],
  305. component: [
  306. {required: true, message: "燃气成份不能为空", trigger: "blur"}
  307. ],
  308. joinInstationTime: [
  309. {required: true, message: "入站时间不能为空", trigger: "blur"}
  310. ],
  311. weight: [
  312. {required: true, message: "运输体积不能为空", trigger: "blur"}
  313. ],
  314. carId: [
  315. {required: true, message: "运输车辆不能为空", trigger: "blur"}
  316. ],
  317. deptId: [
  318. {required: true, message: "所属部门不能为空", trigger: "blur"}
  319. ],
  320. fileUrl: [
  321. {required: true, message: "危化品检测报告不能为空", trigger: "blur"}
  322. ],
  323. attachPaths: [
  324. {required: true, message: "危化品运输车车辆许可不能为空", trigger: "blur"}
  325. ],
  326. }
  327. };
  328. },
  329. created() {
  330. this.getList();
  331. this.getTreeselect();
  332. this.getEnterpriseList();
  333. this.getCarList();
  334. },
  335. methods: {
  336. /** 附件:图片 **/
  337. getUrl(url) {
  338. //获取图片全路径 例:http://{{ ip }}:{{ port }}/group1/M00/00/07/wKgKEGVxMCiAZbvVAAJE9SGvagw915.jpg
  339. this.form.attachPaths = url
  340. //获取图片路径 例:group1/M00/00/07/wKgKEGVxL6eACFv2AAJE9SGvagw622.jpg
  341. // this.form.attachPaths = this.$refs.ImageUpload.dialogName
  342. },
  343. /** 附件:文件 **/
  344. setFileName(fileName) {
  345. let that = this
  346. that.fileNames.push(fileName)
  347. },
  348. removeFileName(index) {
  349. let that = this
  350. that.fileNames.splice(index, 1);
  351. let fileurls = that.form.fileUrl.split(",")
  352. fileurls.splice(index, 1)
  353. that.form.fileUrl = fileurls.toString()
  354. },
  355. /** 获取车辆列表 **/
  356. getCarList(){
  357. getCarList().then(res=>{
  358. this.carList = res.data;
  359. })
  360. },
  361. /** 查询部门下拉树结构 */
  362. getTreeselect() {
  363. treeselect().then(response => {
  364. this.deptOptions = response.data;
  365. });
  366. },
  367. hx(node) {
  368. this.form.dataDeptId = node.id
  369. this.form.deptId = node.id
  370. this.form.deptName = node.label
  371. this.$refs.form.validateField("deptId")
  372. },
  373. handleEnterpriseChange(newId) {
  374. const selectedEnterprise = this.enterpriseList.find(item => item.id === newId);
  375. if (selectedEnterprise) {
  376. this.form.enterpriseName = selectedEnterprise.enterpriseName;
  377. } else {
  378. this.form.enterpriseName = '';
  379. }
  380. },
  381. handleCarChange(newId){
  382. const selectedCar = this.carList.find(item => item.id === newId);
  383. if (selectedCar) {
  384. this.form.carNumber = selectedCar.carNumber;
  385. } else {
  386. this.form.carNumber = '';
  387. }
  388. },
  389. getEnterpriseList(){
  390. getListAll().then(res=>{
  391. this.enterpriseList = res.data
  392. })
  393. },
  394. /** 查询气源数据列表 */
  395. getList() {
  396. this.loading = true;
  397. listGassource(this.queryParams).then(response => {
  398. this.gassourceList = response.rows;
  399. this.total = response.total;
  400. this.loading = false;
  401. });
  402. },
  403. // 取消按钮
  404. cancel() {
  405. this.open = false;
  406. this.reset();
  407. },
  408. // 表单重置
  409. reset() {
  410. this.form = {
  411. id: null,
  412. createBy: null,
  413. createName: null,
  414. createTime: null,
  415. updateBy: null,
  416. updateName: null,
  417. updateTime: null,
  418. deptId: null,
  419. deptName: null,
  420. enterpriseId: null,
  421. enterpriseName: null,
  422. address: null,
  423. component: null,
  424. joinInstationTime: null,
  425. weight: null,
  426. carNumber: null
  427. };
  428. this.fileNames = [];
  429. this.resetForm("form");
  430. },
  431. /** 搜索按钮操作 */
  432. handleQuery() {
  433. this.queryParams.pageNum = 1;
  434. this.getList();
  435. },
  436. /** 重置按钮操作 */
  437. resetQuery() {
  438. this.resetForm("queryForm");
  439. this.handleQuery();
  440. },
  441. // 多选框选中数据
  442. handleSelectionChange(selection) {
  443. this.ids = selection.map(item => item.id)
  444. this.single = selection.length !== 1
  445. this.multiple = !selection.length
  446. },
  447. /** 新增按钮操作 */
  448. handleAdd() {
  449. this.reset();
  450. this.open = true;
  451. this.title = "添加气源数据";
  452. },
  453. /** 修改按钮操作 */
  454. handleUpdate(row) {
  455. this.reset();
  456. const id = row.id || this.ids
  457. getGassource(id).then(response => {
  458. const list = response.data.fileUrl.split(',');
  459. if (response.data.fileUrl != "") {
  460. for (var a = 0; a < list.length; a++) {
  461. let listurl = list[a].split('+')
  462. this.fileNames.push(listurl[1])
  463. }
  464. }
  465. this.form = response.data;
  466. this.open = true;
  467. this.title = "修改气源数据";
  468. });
  469. },
  470. /** 提交按钮 */
  471. submitForm() {
  472. this.$refs["form"].validate(valid => {
  473. if (valid) {
  474. this.form.fileName = this.fileNames.toString()
  475. if (this.form.id != null) {
  476. updateGassource(this.form).then(response => {
  477. this.$modal.msgSuccess("修改成功");
  478. this.fileNames = [];
  479. this.open = false;
  480. this.getList();
  481. });
  482. } else {
  483. addGassource(this.form).then(response => {
  484. this.$modal.msgSuccess("新增成功");
  485. this.open = false;
  486. this.fileNames = [];
  487. this.getList();
  488. });
  489. }
  490. }
  491. });
  492. },
  493. /** 删除按钮操作 */
  494. handleDelete(row) {
  495. const ids = row.id || this.ids;
  496. this.$modal.confirm('是否确认删除选中的数据项?').then(function () {
  497. return delGassource(ids);
  498. }).then(() => {
  499. this.getList();
  500. this.$modal.msgSuccess("删除成功");
  501. }).catch(() => {
  502. });
  503. },
  504. /** 导出按钮操作 */
  505. handleExport() {
  506. this.download('sooka-sponest-center-data/gassource/export', {
  507. ...this.queryParams
  508. }, `气源数据_${format_date(new Date())}.xlsx`)
  509. }
  510. }
  511. };
  512. </script>