product-add-or-update.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <div>
  3. <!-- <el-dialog
  4. :title="!id ? '新增': display ? '详情' : '修改'"
  5. width="70%"
  6. :close-on-click-modal="false"
  7. :visible.sync="visible"> -->
  8. <div class="my-title">{{ !id ? '新增' : display ? '详情' : '修改' }}</div>
  9. <!-- 工作流 -->
  10. <div v-show="display && dataForm.workFlowBusinessExt">
  11. <el-steps
  12. :active="dataForm.workFlowBusinessExt && dataForm.workFlowBusinessExt.workFlowProcessStepList ? dataForm.workFlowBusinessExt.workFlowProcessStepList.length + 2 : 0"
  13. align-center style="margin-bottom: 20px">
  14. <template v-for="(item, i) in stepList">
  15. <el-step :icon="item.icon" :title="item.title" :description="item.description"></el-step>
  16. </template>
  17. </el-steps>
  18. <el-collapse style="margin-bottom: 20px">
  19. <el-collapse-item>
  20. <template slot="title">
  21. <span style="color: red">审批日志(展开查看更多):</span>
  22. </template>
  23. <template v-for="(item, i) in logList">
  24. <div>{{+ + i }}:{{ item.approverName }} {{ item.createTime }} {{ item.approvalValue }}</div>
  25. </template>
  26. </el-collapse-item>
  27. </el-collapse>
  28. </div>
  29. <!-- 表单 -->
  30. <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
  31. <el-row class="my-row">
  32. <el-col :span="8">
  33. <el-form-item label="物料名称" prop="productName">
  34. <el-input v-model="dataForm.productName" :disabled="display" placeholder="物料名称"></el-input>
  35. </el-form-item>
  36. </el-col>
  37. <el-col :span="8">
  38. <el-form-item label="物料规格" prop="productSpec">
  39. <el-input v-model="dataForm.productSpec" :disabled="display" placeholder="物料规格"></el-input>
  40. </el-form-item>
  41. </el-col>
  42. <el-col :span="8">
  43. <el-form-item label="物料类别" prop="productType">
  44. <el-select v-model="dataForm.productType" :disabled="display" remote placeholder="请选择">
  45. <el-option v-for="item in optionsType" :key="item.code" :label="item.value" :value="item.code">
  46. </el-option>
  47. </el-select>
  48. </el-form-item>
  49. </el-col>
  50. </el-row>
  51. <el-row class="my-row">
  52. <el-col :span="8">
  53. <el-form-item label="材料" prop="materials">
  54. <el-input v-model="dataForm.materials" :disabled="display" placeholder="材料"></el-input>
  55. </el-form-item>
  56. </el-col>
  57. <el-col :span="8">
  58. <el-form-item label="物料尺寸" prop="size">
  59. <el-input v-model="dataForm.size" :disabled="display" placeholder="物料尺寸"></el-input>
  60. </el-form-item>
  61. </el-col>
  62. <el-col :span="8">
  63. <el-form-item label="展开尺寸" prop="developedSize">
  64. <el-input v-model="dataForm.developedSize" :disabled="display" placeholder="展开尺寸"></el-input>
  65. </el-form-item>
  66. </el-col>
  67. </el-row>
  68. <el-row class="my-row">
  69. <el-col :span="8">
  70. <el-form-item label="单位" prop="unit">
  71. <el-input v-model="dataForm.unit" :disabled="display" placeholder="单位"></el-input>
  72. </el-form-item>
  73. </el-col>
  74. <el-col :span="8">
  75. <el-form-item label="单套数量" prop="cnt">
  76. <el-input v-model="dataForm.cnt" :disabled="display" placeholder="单套数量"></el-input>
  77. </el-form-item>
  78. </el-col>
  79. <el-col :span="8">
  80. <el-form-item label="主图号" prop="mapNumber">
  81. <el-input v-model="dataForm.mapNumber" :disabled="display" placeholder="主图号"></el-input>
  82. </el-form-item>
  83. </el-col>
  84. </el-row>
  85. <el-row>
  86. <el-col>
  87. <el-form-item label="表面处理" prop="surfaceTreatment">
  88. <el-input v-model="dataForm.surfaceTreatment" :disabled="display" placeholder="" type="textarea"></el-input>
  89. </el-form-item>
  90. </el-col>
  91. </el-row>
  92. <el-row>
  93. <el-col>
  94. <el-form-item label="备注" prop="notes">
  95. <el-input v-model="dataForm.notes" :disabled="display" placeholder="" type="textarea"></el-input>
  96. </el-form-item>
  97. </el-col>
  98. </el-row>
  99. <el-row class="my-row">
  100. <el-col :span="8">
  101. <el-form-item label="简图" prop="attachList2">
  102. <upload-component :accept="'.jpg,.jpeg,.png'" v-model="dataForm.attachList2" />
  103. </el-form-item>
  104. </el-col>
  105. <el-col :span="8" :offset="4">
  106. <el-form-item label="技术资料附件" prop="attachList">
  107. <upload-component :accept="'*'" v-model="dataForm.attachList" />
  108. </el-form-item>
  109. </el-col>
  110. </el-row>
  111. <el-row>
  112. <div class="title"><span style="color: red">*</span> 关联图纸</div>
  113. <el-table :data="drawingList" border style="width: 100%;">
  114. <el-table-column label="序号" type="index" width="50" align="center">
  115. </el-table-column>
  116. <el-table-column prop="drawingName" header-align="center" align="center" label="图纸名称">
  117. </el-table-column>
  118. <el-table-column prop="drawingNo" header-align="center" align="center" label="图号">
  119. </el-table-column>
  120. <el-table-column prop="source" header-align="center" align="center" label="来源">
  121. </el-table-column>
  122. <el-table-column prop="notes" header-align="center" align="center" label="备注">
  123. </el-table-column>
  124. <el-table-column header-align="center" align="center" label="操作">
  125. <template slot-scope="scope">
  126. <el-button type="text" size="small" @click="removeDrawingItem(scope.$index)">移除</el-button>
  127. </template>
  128. </el-table-column>
  129. </el-table>
  130. <el-row style="text-align: center; margin-top: 10px;">
  131. <el-button v-show="!display" type="primary" icon="el-icon-plus" @click="addDrawingList"></el-button>
  132. </el-row>
  133. </el-row>
  134. <el-row class="my-row">
  135. <el-form-item label="是否组合物料" prop="displayProductList">
  136. <el-switch v-model="displayProductList" active-color="#13ce66" inactive-color="#ff4949" active-text="是"
  137. inactive-text="否">
  138. </el-switch>
  139. </el-form-item>
  140. </el-row>
  141. <el-row v-if="displayProductList">
  142. <div class="title"><span style="color: red">*</span> 组合小物料</div>
  143. <el-table :data="productDetails" border style="width: 100%;">
  144. <el-table-column label="序号" type="index" width="50" align="center">
  145. </el-table-column>
  146. <el-table-column prop="productName" header-align="center" align="center" label="物料名称">
  147. </el-table-column>
  148. <el-table-column prop="productSpec" header-align="center" align="center" label="规格">
  149. </el-table-column>
  150. <el-table-column prop="cnt" header-align="center" align="center" label="数量" width="170">
  151. <template slot-scope="scope">
  152. <el-input-number v-model="scope.row.cnt" :disabled="display" :min="1" style="width: 140px;" />
  153. </template>
  154. </el-table-column>
  155. <el-table-column prop="notes" header-align="center" align="center" label="备注">
  156. </el-table-column>
  157. </el-table>
  158. <el-row style="text-align: center; margin-top: 10px;">
  159. <el-button v-show="!display" type="primary" icon="el-icon-plus" @click="addProduct"></el-button>
  160. </el-row>
  161. </el-row>
  162. </el-form>
  163. <span slot="footer" class="dialog-footer">
  164. <el-button @click="onChose">取消</el-button>
  165. <el-button v-if="!display" type="primary" @click="dataFormSubmit()">确定</el-button>
  166. </span>
  167. <!-- </el-dialog> -->
  168. <template-chose v-if="productListVisible" ref="productList" @addItems="addProductItems" />
  169. <templateChoseMaterial v-if="materialListVisible" ref="materialList" @addItems="addMaterialItems" />
  170. <template-draw-choose v-if="drawListVisible" ref="drawList" @addItems="addDrawItems" />
  171. </div>
  172. </template>
  173. <script>
  174. import templateChose from '../product/template-chose'
  175. import templateChoseMaterial from '../product/template-chose-material'
  176. import templateDrawChoose from './draw-template-choose'
  177. import { getDictList } from '@/api/dict'
  178. import { getProductDetail } from '@/api/product'
  179. import UploadComponent from '../common/upload-component-v2'
  180. import { dealStepData, dealStepLogs } from '@/api/util'
  181. import CusComponent from '../common/cus-component'
  182. import DrawComponents from '../common/draw-components'
  183. import DocComponents from '../common/doc-components'
  184. export default {
  185. name: 'product-add-or-update',
  186. components: { DocComponents, DrawComponents, CusComponent, UploadComponent, templateChose, templateChoseMaterial, templateDrawChoose },
  187. computed: {
  188. orgId: {
  189. get () { return this.$store.state.user.orgId }
  190. }
  191. },
  192. // watch: {
  193. // 'dataForm.isCompose' (value) {
  194. // this.dataForm.displayProductList = value === '1'
  195. // }
  196. // },
  197. data () {
  198. return {
  199. productListVisible: false,
  200. materialListVisible: false,
  201. drawListVisible: false,
  202. visible: false,
  203. display: false,
  204. optionsType: [],
  205. // optionsTech: [],
  206. fileList: [],
  207. listingList: [],
  208. dataList: [],
  209. id: 0,
  210. productDetails: [],
  211. materialList: [],
  212. drawingList: [],
  213. displayProductList: false,
  214. dataForm: {
  215. drawingList: []
  216. },
  217. dataRule: {
  218. productName: [{ required: true, message: '请输入物料名称', trigger: 'blur' }],
  219. productSpec: [{ required: true, message: '请输入物料规格', trigger: 'blur' }],
  220. productType: [{ required: true, message: '请选择物料类别', trigger: 'change' }],
  221. materials: [{ required: true, message: '请输入材料', trigger: 'blur' }],
  222. size: [{ required: true, message: '请输入物料尺寸', trigger: 'blur' }],
  223. developedSize: [{ required: true, message: '请输入展开尺寸', trigger: 'blur' }],
  224. unit: [{ required: true, message: '请输入单位', trigger: 'blur' }],
  225. cnt: [{ required: true, message: '请输入单套数量', trigger: 'blur' }],
  226. mapNumber: [{ required: true, message: '请输入主图号', trigger: 'blur' }]
  227. },
  228. stepList: [],
  229. logList: []
  230. }
  231. },
  232. methods: {
  233. onChose () {
  234. this.$emit('onChose')
  235. },
  236. async init (id, display) {
  237. this.fileList = []
  238. this.listingList = []
  239. this.stepList = []
  240. this.logList = []
  241. this.dataForm = {
  242. drawList: []
  243. }
  244. this.productDetails = []
  245. this.materialList = []
  246. // this.optionsTech = []
  247. // this.optionsDraw = []
  248. this.visible = true
  249. this.id = id || 0
  250. this.display = display
  251. // 获取物料类别
  252. await getDictList({ type: 'product_type' }).then(({ data }) => {
  253. if (data) {
  254. this.optionsType = data
  255. }
  256. })
  257. // 物料工艺
  258. if (!id) return
  259. await getProductDetail(this.id).then(({ data }) => {
  260. if (data && data.code === '200') {
  261. this.dataForm = data.data
  262. if (data.data.docs) {
  263. let docIdList = []
  264. data.data.docs.forEach((item) => {
  265. docIdList.push(item.docId)
  266. })
  267. this.dataForm.docIdList = docIdList
  268. }
  269. if (data.data.proDrawings) {
  270. let idList = []
  271. data.data.proDrawings.forEach((item) => {
  272. idList.push(item.drawingId)
  273. })
  274. this.dataForm.drawingIdList = idList
  275. }
  276. // 流程图展示
  277. if (data.data.workFlowBusinessExt) {
  278. dealStepData(data.data.workFlowBusinessExt.workFlowProcessStepList, this.stepList)
  279. dealStepLogs(data.data.workFlowBusinessExt.processLogList, this.logList)
  280. }
  281. // 组合小物料
  282. if (data.data.productMaterialList) {
  283. data.data.productMaterialList.forEach((item) => {
  284. this.productDetails.push({
  285. ...item,
  286. productSpec: item.specifications
  287. })
  288. })
  289. this.displayProductList = true
  290. }
  291. // 物料图纸
  292. this.drawingList = data.data.proDrawings
  293. }
  294. })
  295. },
  296. uploadSuccess (fileList) {
  297. this.fileList = fileList
  298. },
  299. uploadSuccess2 (fileList2) {
  300. this.listingList = fileList2
  301. },
  302. // 添加组合物料
  303. addProduct () {
  304. this.productListVisible = true
  305. this.$nextTick(() => {
  306. this.$refs.productList.init()
  307. })
  308. },
  309. addProductItems (items) {
  310. this.productDetails = []
  311. items.forEach((item) => {
  312. this.addProductItem(item)
  313. })
  314. },
  315. addProductItem (item) {
  316. this.productDetails.push({
  317. proProductId: item.productId,
  318. productName: item.productName,
  319. productSpec: item.productSpec,
  320. cnt: 1,
  321. notes: item.notes
  322. })
  323. },
  324. addMaterial () {
  325. this.materialListVisible = true
  326. this.$nextTick(() => {
  327. this.$refs.materialList.init()
  328. })
  329. },
  330. addMaterialItems (items) {
  331. this.materialList = []
  332. items.forEach((item) => {
  333. this.addMaterialItem(item)
  334. })
  335. },
  336. addMaterialItem (item) {
  337. this.materialList.push({
  338. ...item,
  339. cnt: 0
  340. })
  341. },
  342. validateField (type) {
  343. this.$refs.dataForm.validateField(type)
  344. },
  345. // 表单提交
  346. dataFormSubmit () {
  347. this.$refs['dataForm'].validate((valid) => {
  348. if (valid) {
  349. // 组合小物料
  350. this.dataForm.composeProductMaterialList = []
  351. const b1 = this.displayProductList
  352. this.dataForm.isCompose = b1 === true ? '1' : '0'
  353. if (this.dataForm.isCompose === '1' && this.productDetails.length > 0) {
  354. this.productDetails.forEach((item) => {
  355. this.dataForm.composeProductMaterialList.push({
  356. ...item
  357. })
  358. })
  359. }
  360. if (this.drawingList.length <= 0) {
  361. this.$message.error('请选择关联图纸')
  362. return
  363. }
  364. this.dataForm.drawingList = this.drawingList
  365. this.$http({
  366. url: !this.id ? this.$http.adornUrl(`/biz-service/product/save`) : this.$http.adornUrl(`/biz-service/product/update`),
  367. method: 'post',
  368. data: this.$http.adornData({ ...this.dataForm, orgId: this.orgId })
  369. }).then(({ data }) => {
  370. if (data && data.code === '200') {
  371. this.$message({
  372. message: '操作成功',
  373. type: 'success',
  374. duration: 1500,
  375. onClose: () => {
  376. this.onChose()
  377. this.$emit('refreshDataList')
  378. }
  379. })
  380. } else {
  381. this.$message.error(data.msg)
  382. }
  383. })
  384. }
  385. })
  386. },
  387. docSelectChange (val) {
  388. // console.log(val)
  389. this.dataForm.docIdList = val
  390. },
  391. // 添加关联图纸
  392. addDrawingList () {
  393. this.drawListVisible = true
  394. this.$nextTick(() => {
  395. this.$refs.drawList.init()
  396. })
  397. },
  398. addDrawItems (items) {
  399. items.forEach((item) => {
  400. this.addDrawItem(item)
  401. })
  402. },
  403. addDrawItem (item) {
  404. this.drawingList.push({
  405. drawingId: item.drawingId,
  406. drawingName: item.drawingName,
  407. drawingNo: item.drawingNo,
  408. source: item.source,
  409. notes: item.notes
  410. })
  411. },
  412. removeDrawingItem (index) {
  413. this.drawingList.splice(index, 1)
  414. }
  415. }
  416. }
  417. </script>
  418. <style scoped></style>