inventoryFlowForm.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <div class="property-flow-form">
  3. <el-form :model="propertyForm" label-position="top">
  4. <el-form-item label="资产名称">
  5. <el-cascader v-model="departId" :options="departList" :props="defaultProps" @change="changePart"
  6. placeholder="请选择资产名称">
  7. </el-cascader>
  8. </el-form-item>
  9. <el-form-item label="盘点内容">
  10. <el-input type="text" v-model="propertyForm.inventoryContent" placeholder="请输入盘点内容"></el-input>
  11. </el-form-item>
  12. <el-form-item label="盘点描述" class="hui-textarea">
  13. <el-input type="textarea" v-model="propertyForm.remark" placeholder="请输入盘点描述" resize="none">
  14. </el-input>
  15. </el-form-item>
  16. </el-form>
  17. </div>
  18. </template>
  19. <script>
  20. import {
  21. getDevicePartList
  22. } from '@/httpApi/property'
  23. import projectItem from '@/components/common/projectItem'
  24. import {
  25. findParentIds
  26. } from '@/uitls'
  27. export default {
  28. props: ['flowForm'],
  29. data() {
  30. return {
  31. propertyForm: {
  32. inventoryContent: '',
  33. remark: ''
  34. },
  35. departList: [],
  36. departId: [],
  37. defaultProps: {
  38. children: 'children',
  39. label: 'name',
  40. value: 'id'
  41. },
  42. deviceList: []
  43. }
  44. },
  45. created() {
  46. if (JSON.stringify(this.flowForm) === "{}") return this.getPartList();
  47. this.propertyForm = this.flowForm;
  48. this.getPartList();
  49. },
  50. methods: {
  51. getPartList() {
  52. getDevicePartList(this.$store.getters.organization.id, this.$store.getters.project.id).then(res => {
  53. if (res.state) {
  54. this.departList = res.data;
  55. this.returnChildren(this.departList);
  56. if (this.propertyForm.deviceId) this.departId = findParentIds(this.departList,
  57. -this.propertyForm.deviceId);
  58. }
  59. })
  60. },
  61. returnChildren(data) {
  62. data.forEach(item => {
  63. if (item.children && item.deviceList) {
  64. let obj = item.deviceList.map(res => {
  65. res['deviceId'] = res.id;
  66. res['id'] = -res.id;
  67. return res;
  68. })
  69. item.children = item.children.concat(obj);
  70. this.deviceList = this.deviceList.concat(obj);
  71. }
  72. if (item.children && item.children.length > 0) this.returnChildren(item.children);
  73. });
  74. },
  75. changePart() {
  76. this.propertyForm['deviceId'] = -this.departId[this.departId.length - 1];
  77. this.propertyForm['name'] = this.deviceList.filter(node => node.id === this.departId[this.departId
  78. .length - 1])[0].name;
  79. },
  80. returnForm() {
  81. return {
  82. formData: this.propertyForm,
  83. commonForm: {
  84. projectId: this.$store.getters.project.id,
  85. projectName: this.$store.getters.project.projectName,
  86. projectItemId: '',
  87. projectItemName: '',
  88. projectItemTargetId: '',
  89. projectItemTargetName: '',
  90. projectItemTargetRoomId: '',
  91. projectItemTargetRoomName: '',
  92. deviceId: this.propertyForm.deviceId
  93. }
  94. }
  95. }
  96. },
  97. watch: {
  98. flowForm() {
  99. if (JSON.stringify(this.flowForm) === "{}") return;
  100. this.propertyForm = this.flowForm;
  101. this.getPartList();
  102. }
  103. },
  104. components: {
  105. projectItem
  106. },
  107. }
  108. </script>
  109. <style>
  110. </style>