index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-row>
  5. <el-form-item label="港口名称" prop="fPort">
  6. <el-select
  7. style="width: 200px"
  8. v-model="queryParams.fPort"
  9. placeholder="请选择港口名称"
  10. clearable
  11. size="small"
  12. filterable
  13. :remote-method="portRemoteMethod"
  14. >
  15. <el-option
  16. v-for="dict in portNameOptions"
  17. :key="dict.fId"
  18. :label="dict.fName"
  19. :value="dict.fName"
  20. />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="码头" prop="fName">
  24. <el-select
  25. v-model="queryParams.fName"
  26. style="width: 200px"
  27. placeholder="请选择码头"
  28. clearable
  29. size="small"
  30. @keyup.enter.native="handleQuery"
  31. >
  32. <el-option
  33. v-for="dict in wharfOptions"
  34. :key="dict.fId"
  35. :label="dict.fName"
  36. :value="dict.fName"
  37. />
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item label="状态" prop="fStatus">
  41. <el-select
  42. v-model="queryParams.fStatus"
  43. style="width: 200px"
  44. placeholder="请选择状态"
  45. clearable
  46. size="small"
  47. @keyup.enter.native="handleQuery"
  48. >
  49. <el-option label="正常" value="T"/>
  50. <el-option label="停用" value="F"/>
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item label="录入区间" prop="fBsdate">
  54. <el-date-picker
  55. v-model="queryParams.cLoadDate"
  56. type="daterange"
  57. value-format="yyyy-MM-dd"
  58. range-separator="至"
  59. start-placeholder="开始日期"
  60. end-placeholder="结束日期"
  61. style="width: 250px"
  62. >
  63. </el-date-picker>
  64. </el-form-item>
  65. </el-row>
  66. <div v-show="queryParamsHidden">
  67. <el-row>
  68. <el-form-item label="录入人" prop="createBy">
  69. <el-input
  70. v-model="queryParams.createBy"
  71. style="width: 200px"
  72. placeholder="请输入录入人"
  73. clearable
  74. size="small"
  75. @keyup.enter.native="handleQuery"
  76. />
  77. </el-form-item>
  78. <el-form-item label="备注">
  79. <el-input
  80. v-model="queryParams.remark"
  81. style="width: 200px"
  82. clearable
  83. type="textarea"
  84. size="small"
  85. />
  86. </el-form-item>
  87. </el-row>
  88. </div>
  89. </el-form>
  90. <el-row :gutter="10" class="mb8">
  91. <el-col :span="1.5">
  92. <el-button
  93. type="success"
  94. icon="el-icon-plus"
  95. size="mini"
  96. @click="handleAdd"
  97. v-hasPermi="['shipping:address:add']"
  98. >新增</el-button>
  99. </el-col>
  100. <el-col :span="1.5">
  101. <el-button
  102. type="warning"
  103. icon="el-icon-edit"
  104. size="mini"
  105. :disabled="single"
  106. @click="handleUpdate"
  107. v-hasPermi="['shipping:address:edit']"
  108. >修改</el-button>
  109. </el-col>
  110. <el-col :span="1.5">
  111. <el-button
  112. type="danger"
  113. icon="el-icon-delete"
  114. size="mini"
  115. :disabled="multiple"
  116. @click="handleDelete"
  117. v-hasPermi="['shipping:address:remove']"
  118. >删除</el-button>
  119. </el-col>
  120. <el-col :span="1.5">
  121. <el-button
  122. type="primary"
  123. icon="el-icon-download"
  124. size="mini"
  125. @click="handleExport"
  126. v-hasPermi="['basicdata:wharf:import']"
  127. >导入</el-button>
  128. </el-col>
  129. <el-col :span="1.5">
  130. <el-button
  131. type="primary"
  132. icon="el-icon-download"
  133. size="mini"
  134. @click="handleExport"
  135. v-hasPermi="['shipping:address:export']"
  136. >导出</el-button>
  137. </el-col>
  138. <el-col :span="1.5">
  139. <el-button
  140. type="info"
  141. icon="el-icon-download"
  142. size="mini"
  143. @click="handleExport"
  144. v-hasPermi="['basicdata:wharf:list']"
  145. >取消</el-button>
  146. </el-col>
  147. <el-col style="position: absolute;left:75%" :span="5" >
  148. <el-button size="small" @click="queryParamsHidden ? (queryParamsHidden = false) : (queryParamsHidden = true)">{{ queryParamsHidden ? '隐藏' : '更多' }}</el-button>
  149. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  150. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  151. </el-col>
  152. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  153. </el-row>
  154. <el-table v-loading="loading" :data="corpsList" @selection-change="handleSelectionChange">
  155. <el-table-column type="selection" width="55" align="center" />
  156. <el-table-column type="index" width="55" label="行号" align="center" />
  157. <el-table-column :show-overflow-tooltip="true" label="港口名称" align="center" prop="fPort" width="200px"/>
  158. <el-table-column label="码头编号" align="center" prop="fNo" width="100px"/>
  159. <el-table-column :show-overflow-tooltip="true" label="码头全称" align="center" prop="fName" width="100px"
  160. />
  161. <el-table-column :show-overflow-tooltip="true" label="英文全称" align="center" width="100px" prop="fEname" />
  162. <el-table-column :show-overflow-tooltip="true" label="状态" align="center" prop="fStatus" />
  163. <el-table-column :show-overflow-tooltip="true" label="备注" align="center" prop="remark" />
  164. <el-table-column label="录入人" align="center" prop="createBy" />
  165. <el-table-column label="录入时间" align="center" prop="createTime" width="100">
  166. <template slot-scope="scope">
  167. <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
  168. </template>
  169. </el-table-column>
  170. <el-table-column label="最新修改人" align="center" prop="updateBy" width="100px"/>
  171. <el-table-column label="最新修改时间" align="center" prop="updateTime" width="100">
  172. <template slot-scope="scope">
  173. <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
  174. </template>
  175. </el-table-column>
  176. <el-table-column label="操作" align="center" width="120px" fixed="right">
  177. <template slot-scope="scope">
  178. <el-button
  179. size="mini"
  180. type="text"
  181. icon="el-icon-edit"
  182. @click="handleUpdate(scope.row)"
  183. >查看</el-button>
  184. <el-button
  185. size="mini"
  186. type="text"
  187. icon="el-icon-delete"
  188. @click="handleDelete(scope.row)"
  189. >移除</el-button>
  190. </template>
  191. </el-table-column>
  192. </el-table>
  193. <pagination
  194. v-show="total>0"
  195. :total="total"
  196. :page.sync="queryParams.pageNum"
  197. :limit.sync="queryParams.pageSize"
  198. @pagination="getList"
  199. />
  200. <!-- 添加或修改客户详情对话框 -->
  201. <el-dialog
  202. v-dialogDrag
  203. :fullscreen="dialogFull"
  204. :title="title"
  205. :visible.sync="open"
  206. close-on-click-modal="false"
  207. width="60%"
  208. :close-on-click-modal="false"
  209. append-to-body>
  210. <template slot="title">
  211. <div class="avue-crud__dialog__header">
  212. <span class="el-dialog__title">
  213. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px"></span>
  214. </span>
  215. <div class="avue-crud__dialog__menu enlarge" @click="full">
  216. <i style="cursor: pointer;display: block;width:12px;height:12px;border:1px solid #909399;border-top:3px solid #909399;margin-top: -3px;"></i>
  217. </div>
  218. </div>
  219. </template>
  220. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  221. <el-row>
  222. <el-col :span="12">
  223. <el-form-item label="港口简称" prop="fPort">
  224. <el-select
  225. style="width: 80%"
  226. v-model="form.fPort"
  227. placeholder="请选择港口简称"
  228. :disabled="doNot"
  229. filterable
  230. :remote-method="portRemoteMethod"
  231. >
  232. <el-option
  233. v-for="dict in portNameOptions"
  234. :key="dict.fId"
  235. :label="dict.fName"
  236. :value="dict.fName"
  237. />
  238. </el-select>
  239. </el-form-item>
  240. </el-col>
  241. <el-col :span="12">
  242. <el-form-item label="码头编号" prop="fNo">
  243. <el-input v-model="form.fNo" style="width: 80%" placeholder="请输入编号" :disabled="doNot"/>
  244. </el-form-item>
  245. </el-col>
  246. </el-row>
  247. <el-row>
  248. <el-col :span="12">
  249. <el-form-item label="码头全称" prop="fName">
  250. <el-input v-model="form.fName" style="width: 80%" placeholder="请输入码头名称" :disabled="doNot"/>
  251. </el-form-item>
  252. </el-col>
  253. <el-col :span="12">
  254. <el-form-item label="英文名" prop="fEname">
  255. <el-input v-model="form.fEname" style="width: 80%" placeholder="请输入英文名" :disabled="doNot"/>
  256. </el-form-item>
  257. </el-col>
  258. </el-row>
  259. <el-row>
  260. <el-col :span="12">
  261. <el-form-item label="状态" prop="fStatus">
  262. <el-select v-model="form.fStatus" style="width: 80%" placeholder="请选择状态" :disabled="doNot">
  263. <el-option label="正常" value="T"/>
  264. <el-option label="停用" value="F"/>
  265. </el-select>
  266. </el-form-item>
  267. </el-col>
  268. <el-col :span="12">
  269. <el-form-item label="类型" prop="fTypes">
  270. <el-select style="width: 80%" v-model="form.fTypes" disabled placeholder="请输入编号">
  271. <el-option
  272. v-for="(dict, index) in fTypesOptions"
  273. :key="index.dictValue"
  274. :label="dict.dictLabel"
  275. :value="dict.dictValue"/>
  276. </el-select>
  277. </el-form-item>
  278. </el-col>
  279. </el-row>
  280. <el-row>
  281. <el-col :span="24">
  282. <el-form-item label="备注" prop="remark">
  283. <el-input
  284. v-model="form.remark"
  285. style="width: 100%"
  286. type="textarea"
  287. :autosize="{ minRows: 2}"
  288. placeholder="请输入电话"
  289. :disabled="doNot"/>
  290. </el-form-item>
  291. </el-col>
  292. </el-row>
  293. </el-form>
  294. <div slot="footer" class="dialog-footer">
  295. <el-button type="info" round @click="doNot = false">修 改</el-button>
  296. <el-button type="success" round @click="submitForm" :disabled="doNot">保 存</el-button>
  297. <el-button @click="cancel" round>关 闭</el-button>
  298. </div>
  299. </el-dialog>
  300. </div>
  301. </template>
  302. <script>
  303. import { getwharf,listCorps, getCorps, delCorps, addwharf, getyardNo, getyardName, changeCorpsStatus,exportCorps } from "@/api/kaihe/basicdata/wharf";
  304. import {queryUserVal} from "@/api/system/user";
  305. import { isArray } from '@/utils/validate'
  306. import Vue from 'vue'
  307. import { getportinformation } from '@/api/kaihe/basicdata/portinformation'
  308. Vue.directive('dialogDrag', {
  309. bind(el, binding, vnode, oldVnode) {
  310. const dialogHeaderEl = el.querySelector('.el-dialog__header')
  311. const dragDom = el.querySelector('.el-dialog')
  312. const enlarge = el.querySelector('.enlarge')
  313. dialogHeaderEl.style.cursor = 'move'
  314. // 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
  315. const sty = dragDom.currentStyle || window.getComputedStyle(dragDom, null)
  316. if(enlarge){
  317. enlarge.onclick = (e) => {
  318. dragDom.style.top = '0px'
  319. dragDom.style.left = '0px'
  320. }
  321. }
  322. dialogHeaderEl.onmousedown = (e) => {
  323. // 鼠标按下,计算当前元素距离可视区的距离
  324. const disX = e.clientX - dialogHeaderEl.offsetLeft
  325. const disY = e.clientY - dialogHeaderEl.offsetTop
  326. // 获取到的值带px 正则匹配替换
  327. let styL, styT
  328. // 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px
  329. if (sty.left.includes('%')) {
  330. styL = +document.body.clientWidth * (+sty.left.replace(/\%/g, '') / 100)
  331. styT = +document.body.clientHeight * (+sty.top.replace(/\%/g, '') / 100)
  332. } else {
  333. styL = +sty.left.replace(/\px/g, '')
  334. styT = +sty.top.replace(/\px/g, '')
  335. }
  336. document.onmousemove = function(e) {
  337. // 通过事件委托,计算移动的距离
  338. const l = e.clientX - disX
  339. const t = e.clientY - disY
  340. // 移动当前元素
  341. if ((t + styT) >= 0){
  342. dragDom.style.top = `${t + styT}px`
  343. }
  344. dragDom.style.left = `${l + styL}px`
  345. // 将此时的位置传出去
  346. // binding.value({x:e.pageX,y:e.pageY})
  347. }
  348. document.onmouseup = function(e) {
  349. document.onmousemove = null
  350. document.onmouseup = null
  351. }
  352. }
  353. }
  354. })
  355. export default {
  356. name: "wharf",
  357. components: {
  358. },
  359. data() {
  360. return {
  361. //默认显示第一行
  362. queryParamsHidden:false,
  363. //查看置灰
  364. doNot:true,
  365. //模糊查询港口名称
  366. portNameOptions:[],
  367. //港口类型字典表
  368. fTypesOptions:[],
  369. //模糊查询码头
  370. wharfOptions:[],
  371. //全屏放大
  372. dialogFull:false,
  373. // 遮罩层
  374. loading: true,
  375. // 选中数组
  376. ids: [],
  377. // 非单个禁用
  378. single: true,
  379. // 非多个禁用
  380. multiple: true,
  381. // 显示搜索条件
  382. showSearch: true,
  383. // 总条数
  384. total: 0,
  385. // 客户详情表格数据
  386. corpsList: [],
  387. // 弹出层标题
  388. title: "",
  389. // 是否显示弹出层
  390. open: false,
  391. // 查询参数
  392. queryParams: {
  393. pageNum: 1,
  394. pageSize: 10,
  395. fPort:null,
  396. fName:null,
  397. fStatus:null,
  398. createBy:null,
  399. fBsdate:null,
  400. remark:null
  401. },
  402. // 表单参数
  403. form: {
  404. fPort:null,
  405. fNo:null,
  406. fName:null,
  407. fTypes:'2',
  408. fEname:null,
  409. fStatus:'T',
  410. remark:null
  411. },
  412. // 表单校验
  413. rules: {
  414. fNo: [{ required: true, message: "编号不能为空", trigger: "blur" }],
  415. fName: [{ required: true, message: "名称不能为空", trigger: "blur" }],
  416. fEname: [
  417. {
  418. validator: function(rule, value, callback) {
  419. // 校验英文的正则
  420. if (/[a-zA-z]$/.test(value) == false) {
  421. callback(new Error("请输入英文字母"));
  422. } else {
  423. //校验通过
  424. callback();
  425. }
  426. },
  427. trigger: "blur"
  428. }
  429. ],
  430. fPort:[{ required: true, message: '名称不能为空', trigger: 'blur' }]
  431. }
  432. };
  433. },
  434. created() {
  435. this.getList();
  436. this.getDicts("f_types").then(response => {
  437. this.fTypesOptions = response.data;
  438. });
  439. this.portRemoteMethod()
  440. this.wharfRemoteMethod()
  441. },
  442. methods: {
  443. //模糊查询港口名称
  444. portRemoteMethod(){
  445. let queryParams = { pageNum: 1,};
  446. getportinformation(queryParams).then(response =>{
  447. this.portNameOptions = response.rows
  448. })
  449. },
  450. //模糊查询码头名称
  451. wharfRemoteMethod(){
  452. let queryParams = { pageNum: 1,};
  453. getwharf(queryParams).then((response) => {
  454. this.wharfOptions = response.rows;
  455. });
  456. },
  457. full(){
  458. this.dialogFull = !this.dialogFull
  459. },
  460. /** 查询客户详情列表 */
  461. getList() {
  462. this.loading = true;
  463. listCorps(this.queryParams).then(response => {
  464. this.corpsList = response.rows;
  465. this.total = response.total;
  466. this.loading = false;
  467. });
  468. },
  469. // 取消按钮
  470. cancel() {
  471. this.open = false;
  472. this.reset();
  473. },
  474. // 表单重置
  475. reset() {
  476. this.form = {
  477. fPort:null,
  478. fNo:null,
  479. fName:null,
  480. fTypes:'2',
  481. fEname:null,
  482. fStatus:'T',
  483. remark:null
  484. };
  485. this.resetForm("form");
  486. },
  487. // 状态修改
  488. handleStatusChange(row) {
  489. let text = row.fStatus === "0" ? "启用" : "停用";
  490. this.$confirm('确认要"' + text + '""' + row.fName + '"吗?', "警告", {
  491. confirmButtonText: "确定",
  492. cancelButtonText: "取消",
  493. type: "warning"
  494. }).then(function() {
  495. return changeCorpsStatus(row.fId, row.fStatus);
  496. }).then(() => {
  497. this.msgSuccess(text + "成功");
  498. }).catch(function() {
  499. row.fStatus = row.fStatus === "0" ? "1" : "0";
  500. });
  501. },
  502. /** 搜索按钮操作 */
  503. handleQuery() {
  504. this.queryParams.pageNum = 1;
  505. this.getList();
  506. },
  507. /** 重置按钮操作 */
  508. resetQuery() {
  509. this.resetForm("queryForm");
  510. this.handleQuery();
  511. },
  512. // 多选框选中数据
  513. handleSelectionChange(selection) {
  514. this.ids = selection.map(item => item.fId)
  515. this.single = selection.length!==1
  516. this.multiple = !selection.length
  517. },
  518. /** 新增按钮操作 */
  519. handleAdd() {
  520. this.doNot = false
  521. this.reset();
  522. this.open = true;
  523. this.title = "添加客户详情";
  524. },
  525. /** 修改按钮操作 */
  526. handleUpdate(row) {
  527. this.doNot = true
  528. this.reset();
  529. const fId = row.fId || this.ids
  530. getCorps(fId).then(response => {
  531. this.form = response.data;
  532. this.open = true;
  533. this.title = "修改客户详情";
  534. });
  535. },
  536. /** 提交按钮 */
  537. submitForm() {
  538. this.$refs["form"].validate(valid => {
  539. if (valid) {
  540. if (this.form.fId != null) {
  541. addwharf(this.form).then(response => {
  542. this.msgSuccess("修改成功");
  543. this.open = false;
  544. this.getList();
  545. });
  546. } else {
  547. addwharf(this.form).then(response => {
  548. this.msgSuccess("新增成功");
  549. this.open = false;
  550. this.getList();
  551. });
  552. }
  553. }
  554. });
  555. },
  556. /** 删除按钮操作 */
  557. handleDelete(row) {
  558. const fIds = row.fId || this.ids;
  559. this.$confirm('是否确认删除客户详情编号为"' + fIds + '"的数据项?', "警告", {
  560. confirmButtonText: "确定",
  561. cancelButtonText: "取消",
  562. type: "warning"
  563. }).then(function() {
  564. return delCorps(fIds);
  565. }).then(() => {
  566. this.getList();
  567. this.msgSuccess("删除成功");
  568. })
  569. },
  570. /** 导出按钮操作 */
  571. handleExport() {
  572. const queryParams = this.queryParams;
  573. this.$confirm('是否确认导出所有客户详情数据项?', "警告", {
  574. confirmButtonText: "确定",
  575. cancelButtonText: "取消",
  576. type: "warning"
  577. }).then(function() {
  578. return exportCorps(queryParams);
  579. }).then(response => {
  580. this.download(response.msg);
  581. })
  582. }
  583. }
  584. };
  585. </script>
  586. <style lang="scss" scoped>
  587. .avue-crud__dialog__header {
  588. display: -webkit-box;
  589. display: -ms-flexbox;
  590. display: flex;
  591. -webkit-box-align: center;
  592. -ms-flex-align: center;
  593. align-items: center;
  594. -webkit-box-pack: justify;
  595. -ms-flex-pack: justify;
  596. justify-content: space-between;
  597. }
  598. .el-dialog__title {
  599. color: rgba(0,0,0,.85);
  600. font-weight: 500;
  601. word-wrap: break-word;
  602. }
  603. .avue-crud__dialog__menu {
  604. padding-right: 20px;
  605. float: left;
  606. }
  607. .avue-crud__dialog__menu i {
  608. color: #909399;
  609. font-size: 15px;
  610. }
  611. .el-icon-full-screen{
  612. cursor: pointer;
  613. }
  614. .el-icon-full-screen:before {
  615. content: "\e719";
  616. }
  617. </style>