attribute.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <div>
  3. <el-form
  4. label-width="100px"
  5. :rules="rules"
  6. ref="form"
  7. :model="attributeData"
  8. >
  9. <el-row>
  10. <el-col :span="8" label-width="100px">
  11. <el-form-item label="名称:" prop="name">
  12. <el-input
  13. placeholder=""
  14. v-model="category.name"
  15. disabled
  16. ></el-input>
  17. </el-form-item>
  18. </el-col>
  19. <el-col :span="8" label-width="100px">
  20. <el-form-item label="编码:" prop="code">
  21. <el-input
  22. placeholder=""
  23. v-model="category.code"
  24. disabled
  25. ></el-input>
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="8" label-width="100px">
  29. <el-form-item label="牌号:" prop="brandNum">
  30. <el-input
  31. placeholder=""
  32. v-model="category.brandNum"
  33. disabled
  34. ></el-input>
  35. </el-form-item>
  36. </el-col>
  37. <el-col :span="8" label-width="100px">
  38. <el-form-item label="型号:" prop="modelType">
  39. <el-input
  40. placeholder=""
  41. v-model="category.modelType"
  42. disabled
  43. ></el-input>
  44. </el-form-item>
  45. </el-col>
  46. <el-col :span="8" label-width="100px">
  47. <el-form-item label="规格:" prop="specification">
  48. <el-input
  49. placeholder=""
  50. v-model="category.specification"
  51. disabled
  52. ></el-input>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span="8" label-width="100px">
  56. <el-form-item label="计量单位:" prop="measuringUnit">
  57. <el-input
  58. placeholder=""
  59. v-model="category.measuringUnit"
  60. disabled
  61. ></el-input>
  62. </el-form-item>
  63. </el-col>
  64. <el-col :span="8" label-width="100px">
  65. <el-form-item label="重量单位:" prop="weightUnit">
  66. <el-input
  67. placeholder=""
  68. v-model="category.weightUnit"
  69. disabled
  70. ></el-input>
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="8" label-width="100px">
  74. <el-form-item label="包装单位:" prop="packingUnit">
  75. <el-input
  76. placeholder=""
  77. v-model="category.packingUnit"
  78. disabled
  79. ></el-input>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :span="8" label-width="100px">
  83. <el-form-item label="毛重:" prop="roughWeight">
  84. <el-input
  85. placeholder=""
  86. v-model="category.roughWeight"
  87. disabled
  88. ></el-input>
  89. </el-form-item>
  90. </el-col>
  91. <el-col :span="8" label-width="100px">
  92. <el-form-item label="净重:" prop="netWeight">
  93. <el-input
  94. placeholder=""
  95. v-model="category.netWeight"
  96. disabled
  97. ></el-input>
  98. </el-form-item>
  99. </el-col>
  100. <el-col :span="8" label-width="100px">
  101. <el-form-item
  102. label="加工类型:"
  103. prop="isConsumable"
  104. v-if="[1, 23, 9, 28].includes(Number(category.categoryLevelPathId))"
  105. >
  106. <el-input
  107. placeholder=""
  108. :v-model="category.isConsumable == 1 ? '批量' : '单件'"
  109. disabled
  110. ></el-input>
  111. </el-form-item>
  112. </el-col>
  113. <el-col :span="8" label-width="100px">
  114. <el-form-item label="生产类型:" prop="produceType">
  115. <el-select
  116. v-model="attributeData.produceType"
  117. filterable
  118. multiple
  119. class="ele-block"
  120. >
  121. <el-option
  122. v-for="item in dictList"
  123. :key="item.value"
  124. :value="item.value"
  125. :label="item.label"
  126. ></el-option>
  127. </el-select>
  128. </el-form-item>
  129. </el-col>
  130. </el-row>
  131. <el-row>
  132. <el-col :span="8" label-width="100px">
  133. <el-form-item label="材料" prop="materialsName">
  134. <el-input
  135. placeholder=""
  136. v-model="attributeData.materialsName"
  137. ></el-input>
  138. </el-form-item>
  139. </el-col>
  140. <el-col :span="8" label-width="100px">
  141. <el-form-item label="bom路线" prop="bomTypeRouting">
  142. <el-input
  143. placeholder=""
  144. v-model="attributeData.bomTypeRouting"
  145. ></el-input>
  146. </el-form-item>
  147. </el-col>
  148. </el-row>
  149. <el-row>
  150. <el-col :span="8" label-width="100px">
  151. <el-form-item label="来源" prop="sourceData">
  152. <el-input
  153. placeholder=""
  154. v-model="attributeData.sourceData"
  155. ></el-input>
  156. </el-form-item>
  157. </el-col>
  158. <el-col :span="8" label-width="100px">
  159. <el-form-item label="用量" prop="dosage">
  160. <el-input placeholder="" v-model="attributeData.dosage"></el-input>
  161. </el-form-item>
  162. </el-col>
  163. </el-row>
  164. <el-row>
  165. <el-col :span="8" label-width="100px">
  166. <el-form-item label="基本数量" prop="baseCount">
  167. <el-input
  168. placeholder=""
  169. v-model="attributeData.baseCount"
  170. ></el-input>
  171. </el-form-item>
  172. </el-col>
  173. <el-col :span="8" label-width="100px">
  174. <el-form-item label="物料库路径" prop="name">
  175. <el-input
  176. placeholder=""
  177. v-model="attributeData.materielPath"
  178. ></el-input>
  179. </el-form-item>
  180. </el-col>
  181. </el-row>
  182. <el-row>
  183. <el-col :span="20" label-width="100px">
  184. <el-form-item label="备注" prop="name">
  185. <el-input
  186. placeholder=""
  187. v-model="attributeData.remake"
  188. type="textarea"
  189. :rows="2"
  190. ></el-input>
  191. </el-form-item>
  192. </el-col>
  193. </el-row>
  194. <el-row>
  195. <el-col :span="8" label-width="100px">
  196. <el-form-item label="创建人" prop="name">
  197. <el-input
  198. placeholder=""
  199. disabled
  200. v-model="attributeData.createName"
  201. ></el-input>
  202. </el-form-item>
  203. </el-col>
  204. <el-col :span="8" label-width="100px">
  205. <el-form-item label="创建时间" prop="name">
  206. <el-input
  207. placeholder=""
  208. disabled
  209. v-model="attributeData.createTime"
  210. ></el-input>
  211. </el-form-item>
  212. </el-col>
  213. </el-row>
  214. <div class="btn_box" v-if="attributeData.status != 1">
  215. <el-button type="primary" @click="handleUpdate">保存</el-button>
  216. </div>
  217. </el-form>
  218. </div>
  219. </template>
  220. <script>
  221. import { getByCode } from '@/api/system/dictionary-data';
  222. import { bomCategoryUpdate } from '@/api/material/BOM';
  223. export default {
  224. components: {},
  225. data() {
  226. return {
  227. form: {},
  228. category: {
  229. name: ''
  230. },
  231. statusOptions: [
  232. {
  233. label: '默认',
  234. value: '0'
  235. },
  236. {
  237. label: '归档',
  238. value: '1'
  239. }
  240. ],
  241. bomTypeOptions: [
  242. {
  243. label: 'PBOM',
  244. value: '1'
  245. },
  246. {
  247. label: 'MBOM',
  248. value: '2'
  249. },
  250. {
  251. label: 'ABOM',
  252. value: '3'
  253. }
  254. ],
  255. dictList: [],
  256. rules: {
  257. dosage: [{ required: true, message: ' ', trigger: 'blur' }],
  258. baseCount: [{ required: true, message: ' ', trigger: 'blur' }],
  259. produceType: [{ required: true, message: ' ', trigger: 'blur' }],
  260. },
  261. };
  262. },
  263. created() {
  264. this.getDictList('productionType');
  265. },
  266. beforeDestroy() {},
  267. methods: {
  268. async getDictList(code) {
  269. let { data: res } = await getByCode(code);
  270. this.dictList = res.map((item) => {
  271. let values = Object.keys(item);
  272. return {
  273. value: Number(values[0]),
  274. label: item[values[0]]
  275. };
  276. });
  277. },
  278. handleUpdate() {
  279. this.$refs.form.validate(async (valid) => {
  280. if (valid) {
  281. this.category.produceType = this.attributeData.produceType;
  282. bomCategoryUpdate(this.attributeData).then((res) => {
  283. this.$message.success('修改成功');
  284. });
  285. } else {
  286. return false;
  287. }
  288. });
  289. }
  290. },
  291. props: {
  292. attributeData: {
  293. type: Object,
  294. default: {}
  295. }
  296. },
  297. watch: {
  298. attributeData(val) {
  299. console.log(Object.prototype.hasOwnProperty.call(val, 'category'));
  300. if (Object.prototype.hasOwnProperty.call(val, 'category')) {
  301. this.category = val.category;
  302. this.attributeData.produceType = val.category.produceType;
  303. this.$forceUpdate();
  304. }
  305. }
  306. }
  307. };
  308. </script>
  309. <style lang="scss" scoped>
  310. .btn_box {
  311. display: flex;
  312. align-items: center;
  313. justify-content: center;
  314. }
  315. .el-form-item {
  316. margin-bottom: 10px !important;
  317. }
  318. </style>