depreciation.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <div class="hui-flex">
  3. <div class="hui-flex-box yui-tree-box">
  4. <div class="hui-left-tree">
  5. <div class="hui-left-tree-title">
  6. <svg-icon name="zhuangshi" width="16" height="20"></svg-icon>
  7. <span class="hui-left-tree-sub">资产列表</span>
  8. </div>
  9. <div class="hui-left-tree-content">
  10. <el-collapse>
  11. <el-collapse-item v-for="item in treeData" :key="item.id">
  12. <template slot="title">
  13. <i class="iconfont huifont-shuzhuangcaidantubiao"></i>
  14. <span class="el-collapse-name">{{item.name}}</span>
  15. </template>
  16. <div>
  17. <el-tree :data="item.children" :props="defaultProps">
  18. <div class="custom-tree-node" slot-scope="{ node, data }">
  19. <div class="label">{{node.label}}</div>
  20. <div :class="nowData.id === data.id ? 'active':''"
  21. @click.stop="filterDevice(data)">
  22. <i
  23. :class="'iconfont ' + (data.deviceId ? 'huifont-shebeiguanli' : 'huifont-xiangmuguanli')">
  24. </i>
  25. </div>
  26. </div>
  27. </el-tree>
  28. </div>
  29. </el-collapse-item>
  30. </el-collapse>
  31. </div>
  32. </div>
  33. <div class="hui-tree-content">
  34. <div class="hui-flex hui-content box-background">
  35. <div class="hui-content-title">
  36. <div class="hui-title-item active">资产折旧</div>
  37. </div>
  38. <div class="hui-flex-box hui-flex hui-table">
  39. <div class="hui-content-insert">
  40. <el-button type="primary" size="medium" @click="insert">新增折旧</el-button>
  41. </div>
  42. <div class="hui-flex-box">
  43. <el-table :data="tableData" row-key="id" border height="100%">
  44. <el-table-column label="序号" width="50">
  45. <template slot-scope="scope">
  46. <div style="text-align: center;">{{scope.$index + 1}}</div>
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="资产名称" prop="name"></el-table-column>
  50. <el-table-column label="资产编码" prop="assetNumber"></el-table-column>
  51. <el-table-column label="折旧内容" prop="depreciationContent"></el-table-column>
  52. <el-table-column label="折旧描述" prop="remark"></el-table-column>
  53. <el-table-column label="创建者" prop="createdByUserName"></el-table-column>
  54. <el-table-column label="状态">
  55. <template slot-scope="scope">
  56. <div v-if="!scope.row.state" class="hui-state">
  57. <span class="hui-state-bage hui-state-primary"></span>
  58. <span class="hui-state-label">待生成</span>
  59. </div>
  60. <div v-if="scope.row.state == -1 || scope.row.state == 1" class="hui-state">
  61. <span class="hui-state-bage hui-state-primary"></span>
  62. <span class="hui-state-label">待审核</span>
  63. </div>
  64. <div v-if="scope.row.state == 2" class="hui-state">
  65. <span class="hui-state-bage hui-state-info"></span>
  66. <span class="hui-state-label">审核中</span>
  67. </div>
  68. <div v-if="scope.row.state == 3" class="hui-state">
  69. <span class="hui-state-bage hui-state-success"></span>
  70. <span class="hui-state-label">通过</span>
  71. </div>
  72. <div v-if="scope.row.state == 4" class="hui-state">
  73. <span class="hui-state-bage hui-state-error"></span>
  74. <span class="hui-state-label">未通过</span>
  75. </div>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="操作" width="150">
  79. <template slot-scope="scope">
  80. <div class="hui-table-operation">
  81. <span class="table-operation" @click="lookFlow(scope.row)">
  82. 详情
  83. </span>
  84. <span class="table-operation" v-if="!scope.row.projectFlowId"
  85. @click="updateFlow(scope.row)">
  86. 编辑
  87. </span>
  88. <span class="table-operation" v-if="!scope.row.projectFlowId"
  89. @click="deleteFlow(scope.row)">
  90. 删除
  91. </span>
  92. </div>
  93. </template>
  94. </el-table-column>
  95. <template slot="empty">
  96. <empty description="暂无数据"></empty>
  97. </template>
  98. </el-table>
  99. </div>
  100. <div class="hui-content-pagination">
  101. <el-pagination :pager-count="9" layout="prev, pager, next" :total="totalCount"
  102. @current-change="currentChange">
  103. </el-pagination>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. </div>
  109. <el-dialog :close-on-click-modal="false" :title="isUpdate?'编辑':'新增'" :visible.sync="visible" width="1200px"
  110. :append-to-body="true">
  111. <flow-form v-if="visible" :isUpdate="isUpdate" @callback="callback" :detailId="detailId"
  112. :flowType="flowType">
  113. </flow-form>
  114. </el-dialog>
  115. <el-drawer title="流程详情" :visible.sync="drawer" :size="400" :append-to-body="true">
  116. <flow-detail v-if="drawer" @callback="callback" :detailId="detailId"></flow-detail>
  117. </el-drawer>
  118. </div>
  119. </template>
  120. <script>
  121. import {
  122. initDevicePartList,
  123. getDevicePartList,
  124. getFlowList,
  125. deleteFlow
  126. } from '@/httpApi/property'
  127. import flowForm from '@/components/flow/flowForm'
  128. import flowDetail from '@/components/flow/flowDetail'
  129. export default {
  130. data() {
  131. return {
  132. flowType: 3,
  133. tableData: [],
  134. currPage: 1,
  135. pageSize: 10,
  136. totalCount: 0,
  137. treeData: [],
  138. defaultProps: {
  139. children: 'children',
  140. label: 'name'
  141. },
  142. visible: false,
  143. isUpdate: false,
  144. detailId: '',
  145. drawer: false,
  146. nowData: {},
  147. filterOption: {}
  148. }
  149. },
  150. created() {
  151. this.initDeviceList();
  152. this.init();
  153. },
  154. methods: {
  155. init() {
  156. let filterOption = {
  157. projectId: this.$store.getters.project.id,
  158. flowType: this.flowType
  159. };
  160. filterOption = Object.assign(filterOption, this.filterOption);
  161. getFlowList(this.currPage, this.pageSize, filterOption).then(res => {
  162. if (res.state) {
  163. this.tableData = res.data.dataList.map(node => {
  164. node = Object.assign(node, JSON.parse(node.flowData));
  165. if (node.operateDevice) node['assetNumber'] = node.operateDevice.assetNumber;
  166. return node;
  167. });;
  168. this.totalCount = res.data.totalCount;
  169. }
  170. })
  171. },
  172. initDeviceList() {
  173. getDevicePartList(this.$store.getters.organization.id, this.$store.getters.project.id).then(res => {
  174. if (res.state) {
  175. if (res.data.length === 0) {
  176. initDevicePartList(this.$store.getters.organization.id, this.$store.getters.project.id)
  177. .then(res => {
  178. if (res.state) this.initDeviceList();
  179. })
  180. } else {
  181. this.treeData = res.data;
  182. this.returnChildren(this.treeData);
  183. }
  184. }
  185. })
  186. },
  187. filterDevice(data) {
  188. this.filterOption = {};
  189. if (this.nowData.id === data.id) {
  190. this.nowData = {};
  191. } else {
  192. this.nowData = data;
  193. if (this.nowData.deviceId) {
  194. this.filterOption['deviceId'] = this.nowData.deviceId;
  195. } else {
  196. this.filterOption['deviceLevelId'] = this.nowData.id;
  197. }
  198. }
  199. this.currPage = 1;
  200. this.init();
  201. },
  202. returnChildren(data) {
  203. data.forEach(item => {
  204. if (item.children && item.deviceList) {
  205. let obj = item.deviceList.map(res => {
  206. res['deviceId'] = res.id;
  207. res['id'] = -res.id;
  208. return res;
  209. })
  210. item.children = item.children.concat(obj);
  211. }
  212. if (item.children && item.children.length > 0) this.returnChildren(item.children);
  213. });
  214. },
  215. currentChange(currPage) {
  216. this.currPage = currPage;
  217. this.init();
  218. },
  219. insert() {
  220. this.visible = true;
  221. this.isUpdate = false;
  222. },
  223. lookFlow(val) {
  224. this.detailId = val.id;
  225. this.drawer = true;
  226. },
  227. updateFlow(val) {
  228. this.detailId = val.id;
  229. this.isUpdate = true;
  230. this.visible = true;
  231. },
  232. deleteFlow(val) {
  233. this.$confirm('确定要删除该流程?', () => {
  234. deleteFlow(val.id).then(res => {
  235. if (res.state) {
  236. this.$message.success('操作成功');
  237. this.init();
  238. }
  239. })
  240. });
  241. },
  242. callback(type) {
  243. this.visible = false;
  244. if (type === 'init') this.init();
  245. }
  246. },
  247. components: {
  248. flowForm,
  249. flowDetail
  250. },
  251. }
  252. </script>
  253. <style lang="scss"></style>