index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
  4. <el-form-item label="所属单位" prop="appEncode">
  5. <el-input
  6. v-model="queryParams.appEncode"
  7. placeholder="请输入所属单位"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="车牌号" prop="vehicleNum">
  13. <el-input
  14. v-model="queryParams.vehicleNum"
  15. placeholder="请输入车牌号"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  22. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  23. </el-form-item>
  24. </el-form>
  25. <el-row :gutter="10" class="mb8">
  26. <el-col :span="1.5">
  27. <el-button
  28. type="primary"
  29. icon="el-icon-plus"
  30. size="mini"
  31. @click="handleAdd"
  32. v-hasPermi="['zcustom:platPublicCarChangeDetail:add']"
  33. >新增</el-button>
  34. </el-col>
  35. <el-col :span="1.5">
  36. <el-button
  37. type="danger"
  38. icon="el-icon-delete"
  39. size="mini"
  40. :disabled="multiple"
  41. @click="handleDelete"
  42. v-hasPermi="['zcustom:platPublicCarChangeDetail:remove']"
  43. >删除</el-button>
  44. </el-col>
  45. <el-col :span="1.5">
  46. <el-button
  47. type="warning"
  48. icon="el-icon-upload"
  49. size="mini"
  50. @click="handleUpload"
  51. >导入</el-button>
  52. </el-col>
  53. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  54. </el-row>
  55. <el-table v-loading="loading" :data="platPublicCarChangeDetailList" @selection-change="handleSelectionChange">
  56. <el-table-column type="selection" width="55" align="center" />
  57. <el-table-column label="序号" width="50">
  58. <template slot-scope="scope">
  59. {{(scope.$index + 1) + ((queryParams.pageNum - 1) * queryParams.pageSize)}}
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="所属单位" align="center" prop="appEncode" />
  63. <el-table-column label="车牌号" align="center" prop="vehicleNum" />
  64. <el-table-column label="车辆用途" align="center" prop="useProperty" />
  65. <el-table-column label="资产卡号" align="center" prop="assetsCard" />
  66. <el-table-column label="配置日期" align="center" prop="orgDate" width="180">
  67. <template slot-scope="scope">
  68. <span>{{ parseTime(scope.row.orgDate) }}</span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="处置日期" align="center" prop="handleDate" width="180">
  72. <template slot-scope="scope">
  73. <span>{{ parseTime(scope.row.handleDate) }}</span>
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="处置原因" align="center" prop="handleReason" />
  77. <el-table-column label="类别" align="center" prop="flag">
  78. <template slot-scope="scope">
  79. <span v-if="scope.row.flag === 0">增加</span>
  80. <span v-if="scope.row.flag === 1">减少</span>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
  84. <template slot-scope="scope">
  85. <el-button
  86. size="mini"
  87. type="text"
  88. icon="el-icon-edit"
  89. @click="handleUpdate(scope.row)"
  90. v-hasPermi="['zcustom:platPublicCarChangeDetail:edit']"
  91. >修改</el-button>
  92. <el-button
  93. size="mini"
  94. type="text"
  95. icon="el-icon-delete"
  96. @click="handleDelete(scope.row)"
  97. v-hasPermi="['zcustom:platPublicCarChangeDetail:remove']"
  98. >删除</el-button>
  99. </template>
  100. </el-table-column>
  101. </el-table>
  102. <pagination
  103. v-show="total>0"
  104. :total="total"
  105. :page.sync="queryParams.pageNum"
  106. :limit.sync="queryParams.pageSize"
  107. @pagination="getList"
  108. />
  109. <!-- 添加或修改公务用车年度增加减少对话框 -->
  110. <el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" width="800px" append-to-body>
  111. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  112. <el-form-item label="所属单位" prop="appEncode">
  113. <el-input v-model="form.appEncode" placeholder="请输入所属单位" />
  114. </el-form-item>
  115. <el-form-item label="车牌号" prop="vehicleNum">
  116. <el-input v-model="form.vehicleNum" placeholder="请输入车牌号" />
  117. </el-form-item>
  118. <el-form-item label="车辆用途" prop="useProperty">
  119. <el-input v-model="form.useProperty" placeholder="请输入车辆用途" />
  120. </el-form-item>
  121. <el-form-item label="类别" prop="flag">
  122. <el-radio v-model="form.flag" :label=0>增加</el-radio>
  123. <el-radio v-model="form.flag" :label=1>减少</el-radio>
  124. </el-form-item>
  125. <el-form-item v-if="form.flag===0" label="资产卡号" prop="assetsCard">
  126. <el-input v-model="form.assetsCard" placeholder="请输入资产卡号" />
  127. </el-form-item>
  128. <el-form-item v-if="form.flag===0" label="配置日期" prop="orgDate">
  129. <el-date-picker clearable
  130. v-model="form.orgDate"
  131. type="date"
  132. value-format="yyyy-MM-dd HH:mm:ss"
  133. placeholder="请选择配置日期">
  134. </el-date-picker>
  135. </el-form-item>
  136. <el-form-item v-if="form.flag===1" label="处置日期" prop="handleDate">
  137. <el-date-picker clearable
  138. v-model="form.handleDate"
  139. type="date"
  140. value-format="yyyy-MM-dd HH:mm:ss"
  141. placeholder="请选择处置日期">
  142. </el-date-picker>
  143. </el-form-item>
  144. <el-form-item v-if="form.flag===1" label="处置原因" prop="handleReason">
  145. <el-input v-model="form.handleReason" placeholder="请输入处置原因" />
  146. </el-form-item>
  147. </el-form>
  148. <div slot="footer" class="dialog-footer">
  149. <el-button type="primary" @click="submitForm">确 定</el-button>
  150. <el-button @click="cancel">取 消</el-button>
  151. </div>
  152. </el-dialog>
  153. <el-dialog title="导入json" :visible.sync="op" :close-on-click-modal="false" width="600px" append-to-body>
  154. <el-form ref="form" :rules="rules" label-width="80px">
  155. <el-form-item label="类型">
  156. <el-select v-model="value" placeholder="请选择类型">
  157. <el-option
  158. v-for="item in options"
  159. :key="item.value"
  160. :label="item.label"
  161. :value="item.value">
  162. </el-option>
  163. </el-select>
  164. </el-form-item>
  165. <el-form-item label="json数据">
  166. <el-input v-model="json" type="textarea" placeholder="请输入json数据" />
  167. </el-form-item>
  168. </el-form>
  169. <div slot="footer" class="dialog-footer">
  170. <el-button type="primary" @click="sure">确 定</el-button>
  171. <el-button @click="cancel">取 消</el-button>
  172. </div>
  173. </el-dialog>
  174. </div>
  175. </template>
  176. <script>
  177. import { uploadJson, listPlatPublicCarChangeDetail, getPlatPublicCarChangeDetail, delPlatPublicCarChangeDetail, addPlatPublicCarChangeDetail, updatePlatPublicCarChangeDetail } from "@/api/zcustom/carDetail";
  178. export default {
  179. name: "PlatPublicCarChangeDetail",
  180. data() {
  181. return {
  182. json: undefined,
  183. op:false,
  184. // 根路径
  185. baseURL: process.env.VUE_APP_BASE_API,
  186. // 遮罩层
  187. loading: true,
  188. // 选中数组
  189. ids: [],
  190. // 非单个禁用
  191. single: true,
  192. // 非多个禁用
  193. multiple: true,
  194. // 显示搜索条件
  195. showSearch: true,
  196. // 总条数
  197. total: 0,
  198. // 公务用车年度增加减少表格数据
  199. platPublicCarChangeDetailList: [],
  200. // 弹出层标题
  201. title: "",
  202. // 是否显示弹出层
  203. open: false,
  204. flag:0,
  205. // 查询参数
  206. queryParams: {
  207. pageNum: 1,
  208. pageSize: 10,
  209. appEncode: null,
  210. vehicleNum: null,
  211. useProperty: null,
  212. assetsCard: null,
  213. orgDate: null,
  214. handleDate: null,
  215. handleReason: null,
  216. flag: null
  217. },
  218. // 表单参数
  219. form: {},
  220. value: null,
  221. options:[
  222. {
  223. value: 0,
  224. label: "增加"
  225. }, {
  226. value: 1,
  227. label: "减少"
  228. }],
  229. // 表单校验
  230. rules: {
  231. id: [
  232. { required: true, message: "id不能为空", trigger: "blur" }
  233. ],
  234. delFlag: [
  235. { required: true, message: "删除标志不能为空", trigger: "blur" }
  236. ],
  237. appEncode: [
  238. { required: true, message: "所属单位不能为空", trigger: "blur" }
  239. ],
  240. vehicleNum: [
  241. { required: true, message: "车牌号不能为空", trigger: "blur" }
  242. ],
  243. useProperty: [
  244. { required: true, message: "车辆用途不能为空", trigger: "blur" }
  245. ],
  246. assetsCard: [
  247. { required: true, message: "资产卡号不能为空", trigger: "blur" }
  248. ],
  249. orgDate: [
  250. { required: true, message: "配置日期不能为空", trigger: "blur" }
  251. ],
  252. handleDate: [
  253. { required: true, message: "处置日期不能为空", trigger: "blur" }
  254. ],
  255. handleReason: [
  256. { required: true, message: "处置原因不能为空", trigger: "blur" }
  257. ],
  258. flag: [
  259. { required: true, message: "类别不能为空", trigger: "blur" }
  260. ]
  261. }
  262. };
  263. },
  264. created() {
  265. this.getList();
  266. },
  267. methods: {
  268. sure(){
  269. if (this.value === null){
  270. this.$message.error('请选择类型')
  271. this.json = null
  272. return
  273. }
  274. const jsonString = JSON.parse(this.json)
  275. uploadJson(jsonString, this.value).then(res => {
  276. if (res.code === 200){
  277. this.$message.success('导入成功')
  278. }
  279. else {
  280. this.$message.error('导入失败')
  281. }
  282. this.json = null
  283. this.value = null
  284. })
  285. },
  286. /** 查询公务用车年度增加减少列表 */
  287. getList() {
  288. this.loading = true;
  289. listPlatPublicCarChangeDetail(this.queryParams).then(response => {
  290. this.platPublicCarChangeDetailList = response.data.records;
  291. this.total = response.data.total;
  292. this.loading = false;
  293. });
  294. },
  295. // 取消按钮
  296. cancel() {
  297. this.open = false;
  298. this.json = undefined
  299. this.value = null
  300. this.op = false;
  301. this.reset();
  302. },
  303. // 表单重置
  304. reset() {
  305. this.form = {
  306. id: null,
  307. delFlag: null,
  308. appEncode: null,
  309. vehicleNum: null,
  310. useProperty: null,
  311. assetsCard: null,
  312. orgDate: null,
  313. handleDate: null,
  314. handleReason: null,
  315. flag: null
  316. };
  317. this.resetForm("form");
  318. },
  319. /** 搜索按钮操作 */
  320. handleQuery() {
  321. this.queryParams.pageNum = 1;
  322. this.getList();
  323. },
  324. /** 重置按钮操作 */
  325. resetQuery() {
  326. this.resetForm("queryForm");
  327. this.handleQuery();
  328. },
  329. // 多选框选中数据
  330. handleSelectionChange(selection) {
  331. this.ids = selection.map(item => item.id)
  332. this.single = selection.length!==1
  333. this.multiple = !selection.length
  334. },
  335. /** 新增按钮操作 */
  336. handleAdd() {
  337. this.reset();
  338. this.open = true;
  339. this.title = "添加公务用车年度增加减少";
  340. },
  341. /** 修改按钮操作 */
  342. handleUpdate(row) {
  343. this.reset();
  344. const id = row.id || this.ids
  345. getPlatPublicCarChangeDetail(id).then(response => {
  346. this.form = response.data;
  347. this.open = true;
  348. this.title = "修改公务用车年度增加减少";
  349. });
  350. },
  351. /** 提交按钮 */
  352. submitForm() {
  353. this.$refs["form"].validate(valid => {
  354. if (valid) {
  355. if (this.form.id != null) {
  356. updatePlatPublicCarChangeDetail(this.form).then(response => {
  357. this.$modal.msgSuccess("修改成功");
  358. this.open = false;
  359. this.getList();
  360. });
  361. } else {
  362. addPlatPublicCarChangeDetail(this.form).then(response => {
  363. this.$modal.msgSuccess("新增成功");
  364. this.open = false;
  365. this.getList();
  366. });
  367. }
  368. }
  369. });
  370. },
  371. /** 删除按钮操作 */
  372. handleDelete(row) {
  373. const ids = row.id || this.ids;
  374. this.$modal.confirm('是否确认删除?').then(function() {
  375. return delPlatPublicCarChangeDetail(ids);
  376. }).then(() => {
  377. this.getList();
  378. this.$modal.msgSuccess("删除成功");
  379. }).catch(() => {});
  380. },
  381. /** 导入操作 */
  382. handleUpload(){
  383. this.op = true
  384. }
  385. }
  386. };
  387. </script>