chargingUnit-List.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <div class="mis-pageBox">
  3. <!-- 主页 -->
  4. <el-container>
  5. <el-header height="40px">
  6. <el-row>
  7. <el-col :span="18">
  8. <el-input
  9. v-model="queryParams.searchText"
  10. size="small"
  11. style="width: 300px"
  12. placeholder="输入关键字"
  13. clearable
  14. @keyup.enter.native="clickQuery()"
  15. />
  16. <el-button
  17. type="primary"
  18. size="small"
  19. icon="el-icon-search"
  20. @click="clickQuery()"
  21. >查询</el-button
  22. >
  23. </el-col>
  24. <el-col :span="6" class="list-opCol">
  25. <el-button
  26. type="primary"
  27. size="small"
  28. icon="el-icon-plus"
  29. @click="clickAdd()"
  30. >添加</el-button
  31. >
  32. <el-button
  33. type="primary"
  34. size="small"
  35. icon="el-icon-edit"
  36. @click="clickModify()"
  37. :disabled="disabledModify"
  38. >修改</el-button
  39. >
  40. <el-button
  41. type="danger"
  42. size="small"
  43. icon="el-icon-delete"
  44. @click="clickDelete()"
  45. :disabled="disabledDelete"
  46. >删除</el-button
  47. >
  48. </el-col>
  49. </el-row>
  50. </el-header>
  51. <el-main>
  52. <tfTable
  53. :table-data="dataList"
  54. :column="columns"
  55. :for-id="false"
  56. :pagination="false"
  57. :currentpage="pageInfo.current"
  58. :pagesize="pageInfo.size"
  59. :total="pageInfo.tableTotal"
  60. :border="true"
  61. :multiple="true"
  62. :fixed="true"
  63. :isdelete="false"
  64. :is-select="false"
  65. :stripe="true"
  66. @handleCurrentChange="handleCurrentChange"
  67. @handleSizeChange="handleSizeChange"
  68. @handleSelectionChange="handleSelectionChange"
  69. @rowDblclick="showDetail"
  70. @detail="showDetail"
  71. />
  72. </el-main>
  73. </el-container>
  74. <!-- 详情页 -->
  75. <el-dialog
  76. v-if="dialogVisible"
  77. v-dialogDrag
  78. top="20vh"
  79. :title="dialogTitle"
  80. :visible.sync="dialogVisible"
  81. width="800px"
  82. class="dialog"
  83. >
  84. <tfDetail :detailData="detailData" :editState="editState" ref="dForm" />
  85. <template slot="footer">
  86. <el-button
  87. type="warning"
  88. icon="el-icon-check"
  89. @click="clickSave()"
  90. v-if="!editState"
  91. >确 定</el-button
  92. >
  93. <el-button type="warning" icon="el-icon-close" @click="clickCancel()"
  94. >关 闭</el-button
  95. >
  96. </template>
  97. </el-dialog>
  98. </div>
  99. </template>
  100. <script>
  101. import "@/views/mis/common/assets/styles/misStyle.scss";
  102. import { DateHelper } from "@/views/mis/common/assets/scripts/utils.js";
  103. import { chargingUnit } from "@/views/mis/common/api/codingManagement.js";
  104. import tfTable from "@/views/mis/common/misTable/index.vue";
  105. import tfDetail from "./chargingUnit-form.vue";
  106. export default {
  107. components: { tfTable, tfDetail },
  108. props: ["data"],
  109. data() {
  110. return {
  111. /* ----- 主页 ----- */
  112. queryParams: {
  113. searchText: "",
  114. },
  115. disabledModify: true,
  116. disabledDelete: true,
  117. editType: true, //编辑类型,true:新增;false:修改
  118. loading: false, // 控制表格查询时
  119. pageInfo: {
  120. current: 1,
  121. size: 10,
  122. tableTotal: 1,
  123. "orders[0].asc": "true",
  124. "orders[0].column": "gsbm",
  125. }, // 分页数据
  126. columns: [
  127. {
  128. label: "代收公司编码",
  129. prop: "gsbm",
  130. align: "center",
  131. sortable: true,
  132. },
  133. {
  134. label: "代收公司名称",
  135. prop: "gsmc",
  136. align: "center",
  137. },
  138. {
  139. label: "公司地址",
  140. prop: "gsdz",
  141. align: "center",
  142. },
  143. {
  144. label: "联系电话",
  145. prop: "lxdh",
  146. align: "center",
  147. },
  148. {
  149. label: "是否启用",
  150. prop: "disabled",
  151. align: "center",
  152. formatter: function (row, column, cellValue, index) {
  153. return cellValue == 1 ? "是" : "否";
  154. },
  155. },
  156. {
  157. label: "操作人员",
  158. prop: "czryxm",
  159. align: "center",
  160. },
  161. {
  162. label: "操作时间",
  163. prop: "czsj",
  164. align: "center",
  165. sortable: true,
  166. },
  167. ],
  168. dataList: [], // 表格数据
  169. selectionsData: [], // 表格选中数据
  170. selectedRow: {}, //表格选中行
  171. /* ----- 详情页 ----- */
  172. dialogTitle: "新增",
  173. editState: false, //编辑状态,true:禁用;false:启用
  174. dialogVisible: false,
  175. detailData: {
  176. gsbm: undefined,
  177. gsmc: undefined,
  178. gsdz:undefined,
  179. lxdh:undefined,
  180. czsj: undefined,
  181. disabled: undefined,
  182. czryxm: undefined,
  183. },
  184. };
  185. },
  186. watch: {
  187. selectionsData(value) {
  188. this.disabledModify = this.selectionsData.length !== 1;
  189. this.disabledDelete = this.selectionsData.length == 0;
  190. },
  191. dialogVisible(newVal, oldVal) {
  192. if (!newVal) {
  193. this.resetDetailData();
  194. }
  195. },
  196. },
  197. created() {},
  198. mounted() {
  199. this.bindList();
  200. },
  201. methods: {
  202. /* ----- 方法 ----- */
  203. /**
  204. * @description 绑定列表
  205. */
  206. bindList() {
  207. // 追加分页参数
  208. let params = Object.assign({}, this.pageInfo, this.queryParams);
  209. this.dataList = [];
  210. this.loading = true;
  211. chargingUnit.query(params)
  212. .then((res) => {
  213. if (res.code !== 1) {
  214. this.$message.error("查询失败!");
  215. return;
  216. }
  217. // 数据总数
  218. this.pageInfo.tableTotal = res.result.total;
  219. this.dataList = res.result.records;
  220. })
  221. .catch((ex) => {
  222. this.$message.error("查询失败!");
  223. })
  224. .finally(() => {
  225. this.loading = false;
  226. });
  227. },
  228. resetDetailData() {
  229. // 表单数据
  230. for (var key in this.detailData) {
  231. //console.log("key值:" + key)
  232. this.detailData[key] = undefined;
  233. }
  234. },
  235. add() {
  236. let params = Object.assign({}, this.detailData);
  237. params.czry = this.$store.state.user.userId;
  238. params.czryxm = this.$store.state.user.realName;
  239. chargingUnit.add(params).then((res) => {
  240. if (res.code == 1) {
  241. this.bindList();
  242. this.$message.success("添加成功!");
  243. this.dialogVisible = false;
  244. }
  245. });
  246. },
  247. modify() {
  248. let params = Object.assign({}, this.detailData);
  249. params.czry = this.$store.state.user.userId;
  250. params.czryxm = this.$store.state.user.realName;
  251. params.czsj = DateHelper.getNowFormatDate(true);
  252. chargingUnit.modify(params).then((res) => {
  253. if (res.code == 1) {
  254. this.bindList();
  255. this.$message.success("修改成功!");
  256. this.dialogVisible = false;
  257. }
  258. });
  259. },
  260. delete() {
  261. const ids = this.selectionsData.map((item) => {
  262. return item.code;
  263. });
  264. chargingUnit.delete({ ids: ids.join(",") }).then((res) => {
  265. if (res.code == 1) {
  266. this.bindList();
  267. this.$message.success("删除成功!");
  268. }
  269. });
  270. },
  271. /**
  272. * @description 显示详情
  273. */
  274. showDetail(data) {
  275. this.selectedRow = data;
  276. this.detailData = Object.assign({}, this.selectedRow);
  277. this.dialogTitle = "查看";
  278. this.editState = true;
  279. this.dialogVisible = true; // 显示弹窗
  280. },
  281. /* ----- dom事件 ----- */
  282. /**
  283. * @description 查询
  284. */
  285. clickQuery() {
  286. this.pageInfo.current = 1;
  287. this.bindList();
  288. },
  289. /**
  290. * @description 添加
  291. */
  292. clickAdd() {
  293. this.detailData.czryxm = this.$store.state.user.realName;
  294. this.detailData.czsj = DateHelper.getNowFormatDate(true);
  295. this.editType = true;
  296. this.dialogTitle = "添加";
  297. this.editState = false;
  298. this.dialogVisible = true; // 显示弹窗
  299. },
  300. /**
  301. * @description 修改
  302. */
  303. clickModify() {
  304. this.selectedRow = this.selectionsData[0];
  305. this.detailData = Object.assign({}, this.selectedRow);
  306. this.editType = false;
  307. this.dialogTitle = "修改";
  308. this.editState = false;
  309. this.dialogVisible = true; // 显示弹窗
  310. },
  311. /**
  312. * @description 删除
  313. */
  314. clickDelete() {
  315. this.$confirm("确定删除?", "提示", {
  316. confirmButtonText: "确定",
  317. cancelButtonText: "取消",
  318. type: "warning",
  319. }).then(() => {
  320. this.delete();
  321. });
  322. },
  323. clickCancel() {
  324. this.dialogVisible = false; // 关闭弹窗
  325. },
  326. clickSave() {
  327. let flag = this.$refs.dForm.validate();
  328. if (flag) {
  329. if (this.editType) this.add(); // 新增
  330. else this.modify(); // 修改
  331. }
  332. },
  333. /* ----- 组件事件 ----- */
  334. /**
  335. * @description 改变当前页
  336. */
  337. handleCurrentChange(current) {
  338. this.pageInfo.current = current;
  339. this.bindList();
  340. },
  341. /**
  342. * @description 分页每页条数
  343. */
  344. handleSizeChange(size) {
  345. this.pageInfo.size = size;
  346. this.bindList();
  347. },
  348. /**
  349. * @description 选择改变
  350. */
  351. handleSelectionChange(rows) {
  352. this.selectionsData = rows;
  353. },
  354. },
  355. };
  356. </script>