attribute.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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. :disabled="attributeData.approvalStatus != 0"
  118. filterable
  119. multiple
  120. class="ele-block"
  121. >
  122. <el-option
  123. v-for="item in dictList"
  124. :key="item.value"
  125. :value="item.value"
  126. :label="item.label"
  127. ></el-option>
  128. </el-select>
  129. </el-form-item>
  130. </el-col>
  131. <el-col :span="8" label-width="100px">
  132. <el-form-item label="属性类型:" prop="attributeType">
  133. <el-select
  134. v-model="attributeData.attributeType"
  135. :disabled="attributeData.approvalStatus != 0"
  136. filterable
  137. multiple
  138. class="ele-block"
  139. >
  140. <el-option
  141. v-for="item in attributeList"
  142. :key="item.value"
  143. :value="item.value"
  144. :label="item.label"
  145. ></el-option>
  146. </el-select>
  147. </el-form-item>
  148. </el-col>
  149. </el-row>
  150. <el-row>
  151. <el-col :span="8" label-width="100px">
  152. <el-form-item label="材料" prop="materialsName">
  153. <el-input
  154. placeholder=""
  155. v-model="attributeData.materialsName"
  156. :disabled="attributeData.approvalStatus != 0"
  157. ></el-input>
  158. </el-form-item>
  159. </el-col>
  160. <el-col :span="8" label-width="100px">
  161. <el-form-item label="bom路线" prop="bomTypeRouting">
  162. <el-input
  163. placeholder=""
  164. v-model="attributeData.bomTypeRouting"
  165. :disabled="attributeData.approvalStatus != 0"
  166. ></el-input>
  167. </el-form-item>
  168. </el-col>
  169. </el-row>
  170. <el-row>
  171. <el-col :span="8" label-width="100px">
  172. <el-form-item label="来源" prop="sourceData">
  173. <el-input
  174. placeholder=""
  175. v-model="attributeData.sourceData"
  176. :disabled="attributeData.approvalStatus != 0"
  177. ></el-input>
  178. </el-form-item>
  179. </el-col>
  180. <el-col :span="8" label-width="100px">
  181. <el-form-item label="用量" prop="dosage">
  182. <el-input placeholder="" v-model="attributeData.dosage" :disabled="attributeData.approvalStatus != 0"></el-input>
  183. </el-form-item>
  184. </el-col>
  185. </el-row>
  186. <el-row>
  187. <el-col :span="8" label-width="100px">
  188. <el-form-item label="基本数量" prop="baseCount">
  189. <el-input
  190. placeholder=""
  191. v-model="attributeData.baseCount"
  192. :disabled="attributeData.approvalStatus != 0"
  193. ></el-input>
  194. </el-form-item>
  195. </el-col>
  196. <el-col :span="8" label-width="100px">
  197. <el-form-item label="物料库路径" prop="name">
  198. <el-input
  199. placeholder=""
  200. v-model="attributeData.materielPath"
  201. :disabled="attributeData.approvalStatus != 0"
  202. ></el-input>
  203. </el-form-item>
  204. </el-col>
  205. </el-row>
  206. <el-row>
  207. <el-col :span="20" label-width="100px">
  208. <el-form-item label="备注" prop="name">
  209. <el-input
  210. placeholder=""
  211. v-model="attributeData.remake"
  212. :disabled="attributeData.approvalStatus != 0"
  213. type="textarea"
  214. :rows="2"
  215. ></el-input>
  216. </el-form-item>
  217. </el-col>
  218. </el-row>
  219. <el-row>
  220. <el-col :span="8" label-width="100px">
  221. <el-form-item label="创建人" prop="name">
  222. <el-input
  223. placeholder=""
  224. disabled
  225. v-model="attributeData.createName"
  226. ></el-input>
  227. </el-form-item>
  228. </el-col>
  229. <el-col :span="8" label-width="100px">
  230. <el-form-item label="创建时间" prop="name">
  231. <el-input
  232. placeholder=""
  233. disabled
  234. v-model="attributeData.createTime"
  235. ></el-input>
  236. </el-form-item>
  237. </el-col>
  238. </el-row>
  239. <div class="btn_box" v-if="attributeData.status != 1">
  240. <el-button type="primary" @click="handleUpdate">保存</el-button>
  241. </div>
  242. </el-form>
  243. </div>
  244. </template>
  245. <script>
  246. import { getByCode } from '@/api/system/dictionary-data';
  247. import { bomCategoryUpdate } from '@/api/material/BOM';
  248. export default {
  249. components: {},
  250. data() {
  251. return {
  252. form: {},
  253. category: {
  254. name: ''
  255. },
  256. statusOptions: [
  257. {
  258. label: '默认',
  259. value: '0'
  260. },
  261. {
  262. label: '归档',
  263. value: '1'
  264. }
  265. ],
  266. bomTypeOptions: [
  267. {
  268. label: 'PBOM',
  269. value: '1'
  270. },
  271. {
  272. label: 'MBOM',
  273. value: '2'
  274. },
  275. {
  276. label: 'ABOM',
  277. value: '3'
  278. }
  279. ],
  280. attributeList: [
  281. {
  282. label: '总装',
  283. value: 1
  284. },
  285. {
  286. label: '部件',
  287. value: 2
  288. },
  289. {
  290. label: '零',
  291. value: 3
  292. },{
  293. label: '原材料',
  294. value: 4
  295. }
  296. ],
  297. dictList: [],
  298. rules: {
  299. dosage: [{ required: true, message: ' ', trigger: 'blur' }],
  300. baseCount: [{ required: true, message: ' ', trigger: 'blur' }],
  301. produceType: [{ required: true, message: ' ', trigger: 'blur' }],
  302. attributeType: [{ required: true, message: ' ', trigger: 'blur' }],
  303. },
  304. };
  305. },
  306. created() {
  307. this.getDictList('productionType');
  308. },
  309. beforeDestroy() {},
  310. methods: {
  311. async getDictList(code) {
  312. let { data: res } = await getByCode(code);
  313. this.dictList = res.map((item) => {
  314. let values = Object.keys(item);
  315. return {
  316. value: Number(values[0]),
  317. label: item[values[0]]
  318. };
  319. });
  320. },
  321. handleUpdate() {
  322. this.$refs.form.validate(async (valid) => {
  323. if (valid) {
  324. this.category.produceType = this.attributeData.produceType;
  325. bomCategoryUpdate(this.attributeData).then((res) => {
  326. this.$message.success('修改成功');
  327. });
  328. } else {
  329. return false;
  330. }
  331. });
  332. }
  333. },
  334. props: {
  335. attributeData: {
  336. type: Object,
  337. default: {}
  338. }
  339. },
  340. watch: {
  341. attributeData(val) {
  342. console.log(Object.prototype.hasOwnProperty.call(val, 'category'));
  343. if (Object.prototype.hasOwnProperty.call(val, 'category')) {
  344. this.category = val.category;
  345. this.attributeData.produceType = val.category.produceType;
  346. this.$forceUpdate();
  347. }
  348. }
  349. }
  350. };
  351. </script>
  352. <style lang="scss" scoped>
  353. .btn_box {
  354. display: flex;
  355. align-items: center;
  356. justify-content: center;
  357. }
  358. .el-form-item {
  359. margin-bottom: 10px !important;
  360. }
  361. </style>