index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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="assetNumber">
  5. <el-input
  6. v-model="queryParams.assetNumber"
  7. placeholder="请输入资产编号"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="调整原因" prop="reason">
  13. <el-input
  14. v-model="queryParams.reason"
  15. placeholder="请输入调整原因"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <!-- <el-form-item label="调整单号" prop="orderNumber">
  21. <el-input
  22. v-model="queryParams.orderNumber"
  23. placeholder="请输入调整单号"
  24. clearable
  25. @keyup.enter.native="handleQuery"
  26. />
  27. </el-form-item> -->
  28. <el-form-item label="制单人" prop="preparedBy">
  29. <el-input
  30. v-model="queryParams.preparedBy"
  31. placeholder="请输入制单人"
  32. clearable
  33. @keyup.enter.native="handleQuery"
  34. />
  35. </el-form-item>
  36. <!-- <el-form-item label="制单部门" prop="preparedDepartment">
  37. <el-input
  38. v-model="queryParams.preparedDepartment"
  39. placeholder="请输入制单部门"
  40. clearable
  41. @keyup.enter.native="handleQuery"
  42. />
  43. </el-form-item> -->
  44. <el-form-item label="记录状态" prop="recordStatus">
  45. <el-select v-model="queryParams.recordStatus" placeholder="请选择记录状态" clearable>
  46. <el-option
  47. v-for="dict in dict.type.asset_record_status"
  48. :key="dict.value"
  49. :label="dict.label"
  50. :value="dict.value"
  51. />
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item>
  55. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  56. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  57. </el-form-item>
  58. </el-form>
  59. <el-row :gutter="10" class="mb8">
  60. <el-col :span="1.5">
  61. <el-button
  62. type="primary"
  63. plain
  64. icon="el-icon-plus"
  65. size="mini"
  66. @click="handleAdd"
  67. v-hasPermi="['asset:adjustment:add']"
  68. >新增</el-button>
  69. </el-col>
  70. <el-col :span="1.5">
  71. <el-button
  72. type="success"
  73. plain
  74. icon="el-icon-edit"
  75. size="mini"
  76. :disabled="single"
  77. @click="handleUpdate"
  78. v-hasPermi="['asset:adjustment:edit']"
  79. >修改</el-button>
  80. </el-col>
  81. <el-col :span="1.5">
  82. <el-button
  83. type="info"
  84. plain
  85. icon="el-icon-position"
  86. size="mini"
  87. :disabled="single"
  88. @click="submit"
  89. v-hasPermi="['asset:adjustment:submit']"
  90. >提交</el-button>
  91. </el-col>
  92. <el-col :span="1.5">
  93. <el-button
  94. type="success"
  95. plain
  96. icon="el-icon-check"
  97. size="mini"
  98. :disabled="single"
  99. @click="audit"
  100. v-hasPermi="['asset:adjustment:audit']"
  101. >审核</el-button>
  102. </el-col>
  103. <el-col :span="1.5">
  104. <el-button
  105. type="danger"
  106. plain
  107. icon="el-icon-delete"
  108. size="mini"
  109. :disabled="multiple"
  110. @click="handleDelete"
  111. v-hasPermi="['asset:adjustment:remove']"
  112. >删除</el-button>
  113. </el-col>
  114. <el-col :span="1.5">
  115. <el-button
  116. type="warning"
  117. plain
  118. icon="el-icon-download"
  119. size="mini"
  120. @click="handleExport"
  121. v-hasPermi="['asset:adjustment:export']"
  122. >导出</el-button>
  123. </el-col>
  124. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  125. </el-row>
  126. <el-table v-loading="loading" :data="adjustmentList" @selection-change="handleSelectionChange" v-if="arr">
  127. <el-table-column type="selection" width="55" align="center" />
  128. <el-table-column label="编号" align="center" prop="id" />
  129. <el-table-column label="资产编号" align="center" prop="assetNumber" >
  130. <template slot-scope="scope">
  131. <span>{{ scope.row.assetNumber != null ? assetName(scope.row.assetNumber) : ""}}</span>
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="资产原信息" align="center" prop="originalAssetInfo" >
  135. <template slot-scope="scope">
  136. <div>{{test(scope.row.originalAssetInfo) }}</div>
  137. </template>
  138. </el-table-column>
  139. <el-table-column label="调整原因" align="center" prop="reason" />
  140. <!-- <el-table-column label="调整单号" align="center" prop="orderNumber" /> -->
  141. <el-table-column label="制单人" align="center" prop="preparedBy" />
  142. <el-table-column label="制单部门" align="center" prop="preparedDepartment">
  143. <template slot-scope="scope">
  144. <span v-if="scope.row.preparedDepartment">{{ scope.row.preparedDepartment != null ? deptName(scope.row.preparedDepartment) : ""}}</span>
  145. </template>
  146. </el-table-column>
  147. <el-table-column label="记录状态" align="center" prop="recordStatus">
  148. <template slot-scope="scope">
  149. <dict-tag :options="dict.type.asset_record_status" :value="scope.row.recordStatus"/>
  150. </template>
  151. </el-table-column>
  152. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  153. <template slot-scope="scope">
  154. <el-button
  155. size="mini"
  156. type="text"
  157. icon="el-icon-edit"
  158. @click="handleUpdate(scope.row)"
  159. v-hasPermi="['asset:adjustment:edit']"
  160. >修改</el-button>
  161. <el-button
  162. size="mini"
  163. type="text"
  164. icon="el-icon-delete"
  165. @click="handleDelete(scope.row)"
  166. v-hasPermi="['asset:adjustment:remove']"
  167. >删除</el-button>
  168. </template>
  169. </el-table-column>
  170. </el-table>
  171. <pagination
  172. v-show="total>0"
  173. :total="total"
  174. :page.sync="queryParams.pageNum"
  175. :limit.sync="queryParams.pageSize"
  176. @pagination="getList"
  177. />
  178. <!-- 添加或修改资产调整对话框 -->
  179. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  180. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  181. <el-form-item label="资产编号" prop="assetNumber">
  182. <el-select v-model="form.assetNumber" filterable placeholder="请选择资产编号">
  183. <el-option
  184. v-for="item in informationList"
  185. :key="item.number"
  186. :label="item.name"
  187. :value="item.number"
  188. ></el-option>
  189. </el-select>
  190. </el-form-item>
  191. <el-form-item label="资产原信息" prop="originalAssetInfo">
  192. <el-input v-model="form.originalAssetInfo" type="textarea" placeholder="请输入内容" />
  193. </el-form-item>
  194. <el-form-item label="调整原因" prop="reason">
  195. <el-input v-model="form.reason" placeholder="请输入调整原因" />
  196. </el-form-item>
  197. <!-- <el-form-item label="调整单号" prop="orderNumber">
  198. <el-input v-model="form.orderNumber" placeholder="请输入调整单号" />
  199. </el-form-item> -->
  200. <el-form-item label="制单人" prop="preparedBy">
  201. <el-input v-model="form.preparedBy" placeholder="请输入制单人" />
  202. </el-form-item>
  203. <el-form-item label="制单部门" prop="preparedDepartment">
  204. <treeselect
  205. v-model="form.preparedDepartment"
  206. :options="deptOptions"
  207. :normalizer="normalizer"
  208. placeholder="选择制单部门"
  209. />
  210. </el-form-item>
  211. <!-- <el-form-item label="记录状态" prop="recordStatus">
  212. <el-select v-model="form.recordStatus" placeholder="请选择记录状态">
  213. <el-option
  214. v-for="dict in dict.type.asset_record_status"
  215. :key="dict.value"
  216. :label="dict.label"
  217. :value="parseInt(dict.value)"
  218. ></el-option>
  219. </el-select>
  220. </el-form-item> -->
  221. </el-form>
  222. <div slot="footer" class="dialog-footer">
  223. <el-button type="primary" @click="submitForm">确 定</el-button>
  224. <el-button @click="cancel">取 消</el-button>
  225. </div>
  226. </el-dialog>
  227. </div>
  228. </template>
  229. <script>
  230. import { listAdjustment, getAdjustment, delAdjustment, addAdjustment, updateAdjustment, submitAdjustment, auditAdjustment } from "@/api/asset/adjustment";
  231. import { listDept } from "@/api/system/dept";
  232. import { listInformation } from "@/api/asset/information";
  233. import Treeselect from "@riophae/vue-treeselect";
  234. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  235. export default {
  236. name: "Adjustment",
  237. dicts: ['asset_record_status'],
  238. components:{
  239. Treeselect
  240. },
  241. data() {
  242. return {
  243. // 遮罩层
  244. loading: true,
  245. // 选中数组
  246. ids: [],
  247. // 非单个禁用
  248. single: true,
  249. // 非多个禁用
  250. multiple: true,
  251. // 显示搜索条件
  252. showSearch: true,
  253. // 总条数
  254. total: 0,
  255. // 部门树选项
  256. deptOptions: [],
  257. arr: [],
  258. // 资产调整表格数据
  259. adjustmentList: [],
  260. // 资产信息表格数据
  261. informationList: [],
  262. // 弹出层标题
  263. title: "",
  264. // 是否显示弹出层
  265. open: false,
  266. // 查询参数
  267. queryParams: {
  268. pageNum: 1,
  269. pageSize: 10,
  270. assetNumber: null,
  271. originalAssetInfo: null,
  272. reason: null,
  273. orderNumber: null,
  274. preparedBy: null,
  275. preparedDepartment: null,
  276. recordStatus: null
  277. },
  278. // 表单参数
  279. form: {},
  280. // 表单校验
  281. rules: {
  282. // assetNumber: [
  283. // { required: true, message: "资产编号不能为空", trigger: "blur" }
  284. // ],
  285. originalAssetInfo: [
  286. { required: true, message: "资产原信息", trigger: "blur" }
  287. ],
  288. orderNumber: [
  289. { required: true, message: "调整单号不能为空", trigger: "blur" }
  290. ],
  291. preparedBy: [
  292. { required: true, message: "制单人不能为空", trigger: "blur" }
  293. ],
  294. recordStatus: [
  295. { required: true, message: "记录状态不能为空", trigger: "change" }
  296. ]
  297. }
  298. };
  299. },
  300. created() {
  301. this.getList();
  302. },
  303. methods: {
  304. test(val) {
  305. const json = JSON.parse(val)
  306. console.log(json)
  307. },
  308. /** 查询资产调整列表 */
  309. getList() {
  310. this.loading = true;
  311. listDept().then((response) => {
  312. this.deptOptions = this.handleTree(response.data, "deptId");
  313. this.arr = response.data
  314. });
  315. listInformation().then(response => {
  316. this.informationList = response.rows;
  317. });
  318. listAdjustment(this.queryParams).then(response => {
  319. this.adjustmentList = response.rows;
  320. this.total = response.total;
  321. this.loading = false;
  322. });
  323. },
  324. /** 转换部门数据结构 */
  325. normalizer(node) {
  326. if (node.children && !node.children.length) {
  327. delete node.children;
  328. }
  329. return {
  330. id: node.deptId,
  331. label: node.deptName,
  332. children: node.children,
  333. };
  334. },
  335. //获取公司名
  336. deptName(val){
  337. let num = parseInt(val)
  338. let arr2 = this.arr.filter(item => item.deptId===num);
  339. if (arr2) {
  340. return arr2[0].deptName
  341. }
  342. },
  343. //获取资产名
  344. assetName(val){
  345. let arr2 = this.informationList.filter(item => item.number===val);
  346. return arr2[0].name
  347. },
  348. // 取消按钮
  349. cancel() {
  350. this.open = false;
  351. this.reset();
  352. },
  353. // 表单重置
  354. reset() {
  355. this.form = {
  356. id: null,
  357. assetNumber: null,
  358. originalAssetInfo: null,
  359. reason: null,
  360. orderNumber: null,
  361. preparedBy: null,
  362. preparedDepartment: null,
  363. recordStatus: null
  364. };
  365. this.resetForm("form");
  366. },
  367. /** 搜索按钮操作 */
  368. handleQuery() {
  369. this.queryParams.pageNum = 1;
  370. this.getList();
  371. },
  372. /** 重置按钮操作 */
  373. resetQuery() {
  374. this.resetForm("queryForm");
  375. this.handleQuery();
  376. },
  377. // 多选框选中数据
  378. handleSelectionChange(selection) {
  379. this.ids = selection.map(item => item.id)
  380. this.single = selection.length!==1
  381. this.multiple = !selection.length
  382. },
  383. /** 新增按钮操作 */
  384. handleAdd() {
  385. this.reset();
  386. this.open = true;
  387. this.title = "添加资产调整";
  388. },
  389. /** 修改按钮操作 */
  390. handleUpdate(row) {
  391. this.reset();
  392. const id = row.id || this.ids
  393. getAdjustment(id).then(response => {
  394. this.form = response.data;
  395. this.open = true;
  396. this.title = "修改资产调整";
  397. });
  398. },
  399. submit(row){
  400. this.reset();
  401. const id = row.id || this.ids
  402. getAdjustment(id).then(response => {
  403. submitAdjustment(response.data).then(response => {
  404. this.$modal.msgSuccess("提交成功");
  405. this.open = false;
  406. this.getList();
  407. });
  408. });
  409. },
  410. /**审核按钮 */
  411. audit(row){
  412. this.reset();
  413. const id = row.id || this.ids
  414. getAdjustment(id).then(response => {
  415. auditAdjustment(response.data).then(response => {
  416. this.$modal.msgSuccess("审核成功");
  417. this.open = false;
  418. this.getList();
  419. });
  420. });
  421. },
  422. /** 提交按钮 */
  423. submitForm() {
  424. this.$refs["form"].validate(valid => {
  425. if (valid) {
  426. if (this.form.id != null) {
  427. updateAdjustment(this.form).then(response => {
  428. this.$modal.msgSuccess("修改成功");
  429. this.open = false;
  430. this.getList();
  431. });
  432. } else {
  433. addAdjustment(this.form).then(response => {
  434. this.$modal.msgSuccess("新增成功");
  435. this.open = false;
  436. this.getList();
  437. });
  438. }
  439. }
  440. });
  441. },
  442. /** 删除按钮操作 */
  443. handleDelete(row) {
  444. const ids = row.id || this.ids;
  445. this.$modal.confirm('是否确认删除资产调整编号为"' + ids + '"的数据项?').then(function() {
  446. return delAdjustment(ids);
  447. }).then(() => {
  448. this.getList();
  449. this.$modal.msgSuccess("删除成功");
  450. }).catch(() => {});
  451. },
  452. /** 导出按钮操作 */
  453. handleExport() {
  454. this.download('asset/adjustment/export', {
  455. ...this.queryParams
  456. }, `adjustment_${new Date().getTime()}.xlsx`)
  457. }
  458. }
  459. };
  460. </script>