order-add-or-update.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. <!-- 任务单新增或修改 -->
  2. <template>
  3. <div>
  4. <div class="my-title">{{ !id ? '新增': display ? '详情' : '修改' }}</div>
  5. <!-- 工作流 -->
  6. <div v-show="display && dataForm.workFlowBusinessExt">
  7. <el-steps :active="dataForm.workFlowBusinessExt&&dataForm.workFlowBusinessExt.workFlowProcessStepList?dataForm.workFlowBusinessExt.workFlowProcessStepList.length + 2:0" align-center style="margin-bottom: 20px">
  8. <template v-for="(item, i) in stepList">
  9. <el-step :icon="item.icon" :title="item.title" :description="item.description"></el-step>
  10. </template>
  11. </el-steps>
  12. <el-collapse style="margin-bottom: 20px">
  13. <el-collapse-item>
  14. <template slot="title">
  15. <span style="color: red">审批日志(展开查看更多):</span>
  16. </template>
  17. <template v-for="(item, i) in logList">
  18. <div>{{++i}}:{{item.approverName}} {{item.createTime}} {{item.approvalValue}}</div>
  19. </template>
  20. </el-collapse-item>
  21. </el-collapse>
  22. </div>
  23. <!-- 表单 -->
  24. <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
  25. <el-row class="my-row">
  26. <el-col :span="8">
  27. <el-form-item label="任务单编码" prop="orderCode">
  28. <el-input v-model="dataForm.orderCode" :disabled="true" placeholder="系统自动生成"></el-input>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="8" style="padding-left: 20px">
  32. <el-form-item label="合同号" prop="contractNumber">
  33. <el-input v-model="dataForm.contractNumber" :disabled="display || addType === 2" placeholder="合同号"></el-input>
  34. </el-form-item>
  35. </el-col>
  36. <el-col :span="8" style="padding-left: 20px">
  37. <el-form-item label="客户名称" prop="customerId">
  38. <el-input v-if="display || addType === 2" v-model="dataForm.customerName" disabled></el-input>
  39. <cus-component v-else v-model="dataForm.customerId" :disabled="display || addType === 2" :cus-id="dataForm.customerId"></cus-component>
  40. </el-form-item>
  41. </el-col>
  42. </el-row>
  43. <el-row class="my-row">
  44. <el-col :span="8">
  45. <el-form-item label="业务员" prop="salesmanId">
  46. <el-input v-if="display || addType === 2" v-model="dataForm.salesmanName" disabled></el-input>
  47. <user-component v-else v-model="dataForm.salesmanId" :user-id="dataForm.salesmanId" @userSelected="salesmanChanged"></user-component>
  48. </el-form-item>
  49. </el-col>
  50. <el-col :span="8" style="padding-left: 20px">
  51. <el-form-item label="合同交期" prop="deliveryDate">
  52. <el-input v-if="display || addType === 2" v-model="dataForm.deliveryDate" disabled></el-input>
  53. <el-date-picker v-else
  54. v-model="dataForm.deliveryDate"
  55. value-format="yyyy-MM-dd"
  56. type="date">
  57. </el-date-picker>
  58. </el-form-item>
  59. </el-col>
  60. </el-row>
  61. <el-row class="my-row">
  62. <el-form-item label="备注说明" prop="notes">
  63. <el-input type="textarea" v-model="dataForm.notes" :disabled="display || addType === 2" placeholder="备注说明" ></el-input>
  64. </el-form-item>
  65. </el-row>
  66. <el-row class="my-row">
  67. <div class="title"><span style="color: red">*</span> 物料清单明细</div>
  68. <el-table
  69. :data="productDetails"
  70. border
  71. style="width: 100%;">
  72. <el-table-column
  73. label="序号"
  74. type="index"
  75. width="50"
  76. align="center">
  77. </el-table-column>
  78. <el-table-column
  79. prop="productName"
  80. header-align="center"
  81. align="center"
  82. width="160"
  83. :show-tooltip-when-overflow="true"
  84. label="物料名称">
  85. </el-table-column>
  86. <el-table-column
  87. prop="productSpecifications"
  88. header-align="center"
  89. align="center"
  90. width="120"
  91. :show-tooltip-when-overflow="true"
  92. label="规格">
  93. </el-table-column>
  94. <el-table-column
  95. prop="cnt"
  96. header-align="center"
  97. align="center"
  98. width="80"
  99. label="数量">
  100. </el-table-column>
  101. <el-table-column
  102. prop="cnt"
  103. header-align="center"
  104. align="center"
  105. width="80"
  106. label="单位">
  107. </el-table-column>
  108. <el-table-column
  109. prop="productNumber"
  110. header-align="center"
  111. align="center"
  112. width="120"
  113. :show-tooltip-when-overflow="true"
  114. label="生产编号">
  115. </el-table-column>
  116. <el-table-column
  117. prop="batchNumber"
  118. header-align="center"
  119. align="center"
  120. width="120"
  121. :show-tooltip-when-overflow="true"
  122. label="批次号">
  123. </el-table-column>
  124. <el-table-column
  125. prop="produceRequire"
  126. header-align="center"
  127. align="center"
  128. width="160"
  129. :show-tooltip-when-overflow="true"
  130. label="生产要求">
  131. </el-table-column>
  132. <el-table-column
  133. prop="price"
  134. header-align="center"
  135. align="center"
  136. width="80"
  137. label="含税单价">
  138. </el-table-column>
  139. <el-table-column
  140. prop="amount"
  141. header-align="center"
  142. align="center"
  143. width="80"
  144. label="含税总价">
  145. <template slot-scope="scope">
  146. <span>{{ (scope.row.cnt*scope.row.price).toFixed(1) }}</span>
  147. </template>
  148. </el-table-column>
  149. <el-table-column
  150. prop="rate"
  151. header-align="center"
  152. align="center"
  153. width="100"
  154. label="税率">
  155. <template slot-scope="scope">
  156. {{scope.row.rate}}%
  157. </template>
  158. </el-table-column>
  159. <el-table-column
  160. prop="notes"
  161. header-align="center"
  162. align="center"
  163. width="120"
  164. :show-tooltip-when-overflow="true"
  165. label="备注">
  166. </el-table-column>
  167. <el-table-column
  168. prop="relatedProduct"
  169. header-align="center"
  170. align="center"
  171. width="120"
  172. :show-tooltip-when-overflow="true"
  173. label="物料关联">
  174. </el-table-column>
  175. <el-table-column
  176. prop="appraisal"
  177. header-align="center"
  178. align="center"
  179. width="120"
  180. :show-tooltip-when-overflow="true"
  181. label="首件鉴定">
  182. <template slot-scope="scope">
  183. <span>{{!scope.row.appraisal?'':(Number(scope.row.appraisal) === 2?'是':'否')}}</span>
  184. </template>
  185. </el-table-column>
  186. <el-table-column
  187. fixed="right"
  188. header-align="center"
  189. align="center"
  190. width="100"
  191. label="操作">
  192. <template slot-scope="scope">
  193. <el-button type="text" size="small" @click="updateProductHandle(scope.row)">编辑</el-button>
  194. <el-button style="color: red" type="text" size="small" @click="deleteProductHandle(scope.row.recordId)">删除</el-button>
  195. </template>
  196. </el-table-column>
  197. </el-table>
  198. <el-row style="text-align: center; margin-top: 10px;">
  199. <el-button :disabled="addType === 2" v-show="!display" type="primary" icon="el-icon-plus" @click="addProductHandle"></el-button>
  200. </el-row>
  201. </el-row>
  202. <el-row class="my-row">
  203. <div class="title"><span style="color: red">*</span> 任务工单派发</div>
  204. <el-table
  205. :data="workInfoDetails"
  206. border
  207. style="width: 100%;">
  208. <el-table-column
  209. label="序号"
  210. type="index"
  211. width="50"
  212. align="center">
  213. </el-table-column>
  214. <el-table-column
  215. prop="taskType"
  216. header-align="center"
  217. align="center"
  218. min-width="80"
  219. :show-tooltip-when-overflow="true"
  220. label="工单类型">
  221. </el-table-column>
  222. <el-table-column
  223. prop="taskName"
  224. header-align="center"
  225. align="center"
  226. width="120"
  227. :show-tooltip-when-overflow="true"
  228. label="工单名称">
  229. </el-table-column>
  230. <el-table-column
  231. prop="ranks"
  232. header-align="center"
  233. align="center"
  234. min-width="50"
  235. label="级别">
  236. </el-table-column>
  237. <el-table-column
  238. prop="content"
  239. header-align="center"
  240. align="center"
  241. width="160"
  242. :show-tooltip-when-overflow="true"
  243. label="工单内容">
  244. </el-table-column>
  245. <el-table-column
  246. prop="receiver"
  247. header-align="center"
  248. align="center"
  249. min-width="100"
  250. label="任务接收人">
  251. </el-table-column>
  252. <el-table-column
  253. prop="planCompletionTime"
  254. header-align="center"
  255. align="center"
  256. min-width="80"
  257. label="要求完成时间">
  258. </el-table-column>
  259. <el-table-column
  260. prop="attachList"
  261. header-align="center"
  262. align="center"
  263. label="工单附件">
  264. <template slot-scope="scope">
  265. <div v-for="(item, index) in scope.row.attachList" style="display: inline">
  266. <span v-if="index > 0">,</span>
  267. <a :key="item.fileName + index" type="primary" href="#" @click="previewFile(item.fileName, item.url)">{{ item.fileName }}</a>
  268. </div>
  269. </template>
  270. </el-table-column>
  271. <el-table-column
  272. prop="notes"
  273. header-align="center"
  274. align="center"
  275. width="120"
  276. :show-tooltip-when-overflow="true"
  277. label="备注">
  278. </el-table-column>
  279. <el-table-column
  280. fixed="right"
  281. header-align="center"
  282. align="center"
  283. width="100"
  284. label="操作">
  285. <template slot-scope="scope">
  286. <el-button type="text" size="small" @click="updateWorkItemHandle(scope.row)">编辑</el-button>
  287. <el-button style="color: red" type="text" size="small" @click="deleteWorkItemHandle(scope.row.recordId)">删除</el-button>
  288. </template>
  289. </el-table-column>
  290. </el-table>
  291. <el-row style="text-align: center; margin-top: 10px;">
  292. <el-button :disabled="addType === 2" v-show="!display" type="primary" icon="el-icon-plus" @click="addWorkItemHandle"></el-button>
  293. </el-row>
  294. </el-row>
  295. </el-form>
  296. <span slot="footer" class="dialog-footer">
  297. <el-button @click="onChose">取消</el-button>
  298. <el-button v-if="!display" type="primary" @click="dataFormSubmit()">确定</el-button>
  299. </span>
  300. <add-or-update v-if="productListVisible" ref="productList" @addItem="addItem" />
  301. <worder-add-or-update v-if="worderListVisible" ref="worderList" @submit="addWorkItem"/>
  302. <!-- 文件预览 -->
  303. <preview-component v-if="previewVisible" ref="preview"/>
  304. </div>
  305. </template>
  306. <script>
  307. import { getOrderDetail } from '@/api/sale'
  308. import UserComponent from '../common/user-component'
  309. import UploadComponent from '../common/upload-component'
  310. import { dealStepData, dealStepLogs } from '@/api/util'
  311. import CusComponent from '../common/cus-component'
  312. import AddOrUpdate from '../product/template-add-or-update'
  313. import WorderAddOrUpdate from '../worder/add-or-update'
  314. import PreviewComponent from '@/views/modules/common/preview-component'
  315. export default {
  316. name: 'order-add-or-update',
  317. components: {PreviewComponent, WorderAddOrUpdate, CusComponent, UploadComponent, UserComponent, AddOrUpdate},
  318. computed: {
  319. orgId: {
  320. get () { return this.$store.state.user.orgId }
  321. }
  322. },
  323. data () {
  324. return {
  325. productListVisible: false,
  326. worderListVisible: false,
  327. previewVisible: false,
  328. visible: false,
  329. display: false,
  330. addType: 0,
  331. fileList: [],
  332. dataList: [],
  333. id: 0,
  334. productDetails: [], // 任务单物料明细
  335. workInfoDetails: [], // 任务工单派发列表
  336. dataForm: {},
  337. dataRule: {
  338. customerId: [{ required: true, message: '客户名称不能为空', trigger: 'change' }],
  339. salesmanId: [{ required: true, message: '业务员不能为空', trigger: 'change' }],
  340. deliveryDate: [{ required: true, message: '合同交期不能为空', trigger: 'change' }]
  341. },
  342. stepList: [],
  343. logList: []
  344. }
  345. },
  346. methods: {
  347. onChose () {
  348. this.productListVisible = false
  349. this.worderListVisible = false
  350. this.$emit('onChose')
  351. },
  352. // 初始化:addType 新增类型: 0新增,1修改 2技术确认 (目前只有2才会赋值)
  353. async init (id, display, addType) {
  354. if (addType) {
  355. this.addType = addType
  356. }
  357. this.fileList = []
  358. this.stepList = []
  359. this.logList = []
  360. this.dataForm = {
  361. rateVal: 0
  362. }
  363. this.productDetails = []
  364. this.visible = true
  365. this.id = id || 0
  366. this.display = display
  367. if (!id) return
  368. await getOrderDetail(this.id).then(({data}) => {
  369. if (data && data.code === '200') {
  370. this.dataForm = data.data
  371. // 流程图展示
  372. dealStepData(data.data.workFlowBusinessExt.workFlowProcessStepList, this.stepList)
  373. dealStepLogs(data.data.workFlowBusinessExt.processLogList, this.logList)
  374. // 附件
  375. if (data.data.attachList) {
  376. data.data.attachList.forEach((item) => {
  377. this.fileList.push({
  378. name: item.fileName,
  379. url: item.url,
  380. id: item.url
  381. })
  382. })
  383. }
  384. // 任务单物料明细
  385. if (data.data.saleROrderProductParamsList) {
  386. data.data.saleROrderProductParamsList.forEach((item) => {
  387. this.addItem(item)
  388. })
  389. }
  390. // 任务工单派发
  391. if (data.data.workInfoList) {
  392. data.data.workInfoList.forEach((item) => {
  393. this.addWorkItem(item)
  394. })
  395. }
  396. }
  397. })
  398. },
  399. uploadSuccess (fileList) {
  400. this.fileList = fileList
  401. },
  402. addItem (item) {
  403. if (!item.recordId) {
  404. item.recordId = Math.round(Math.random() * 1000000)
  405. }
  406. if (this.productDetails.findIndex(item1 => item1.recordId === item.recordId) === -1) {
  407. this.productDetails.push({
  408. ...item
  409. })
  410. }
  411. },
  412. addWorkItem (item) {
  413. this.worderListVisible = false
  414. if (!item.recordId) {
  415. item.recordId = Math.round(Math.random() * 1000000)
  416. }
  417. if (this.workInfoDetails.findIndex(item1 => item1.recordId === item.recordId) === -1) {
  418. this.workInfoDetails.push({
  419. ...item
  420. })
  421. }
  422. },
  423. validateField (type) {
  424. this.$refs.dataForm.validateField(type)
  425. },
  426. // 表单提交
  427. dataFormSubmit () {
  428. this.$refs['dataForm'].validate((valid) => {
  429. if (valid) {
  430. // 合同扫描件
  431. let fList = this.fileList
  432. if (fList.length > 0) {
  433. this.dataForm.attachList = []
  434. for (let i = 0; i < fList.length; i++) {
  435. this.dataForm.attachList.push({
  436. fileName: fList[i].name,
  437. url: fList[i].url
  438. })
  439. }
  440. }
  441. // 任务单物料明细
  442. let pList = this.productDetails
  443. if (pList.length > 0) {
  444. this.dataForm.saleROrderProductParamsList = pList
  445. } else {
  446. this.$message.error('请添加任务单物料明细')
  447. return
  448. }
  449. // 任务工单派发列表
  450. let pList2 = this.workInfoDetails
  451. if (pList2.length > 0) {
  452. this.dataForm.workInfoList = pList2
  453. } else {
  454. this.$message.error('请添加任务工单派发')
  455. return
  456. }
  457. this.$http({
  458. url: !this.id
  459. ? this.$http.adornUrl(`/biz-service/order/save`)
  460. : (this.addType === 2
  461. ? this.$http.adornUrl(`/biz-service/order/determine`)
  462. : this.$http.adornUrl(`/biz-service/order/update`)),
  463. method: 'post',
  464. data: this.$http.adornData({...this.dataForm, orgId: this.orgId})
  465. }).then(({data}) => {
  466. if (data && data.code === '200') {
  467. this.$message({
  468. message: '操作成功',
  469. type: 'success',
  470. duration: 1500,
  471. onClose: () => {
  472. this.onChose()
  473. this.$emit('refreshDataList')
  474. }
  475. })
  476. } else {
  477. this.$message.error(data.msg)
  478. }
  479. })
  480. }
  481. })
  482. },
  483. // 业务员选择变化
  484. salesmanChanged (val) {
  485. this.dataForm.salesmanId = val
  486. },
  487. // 添加订单产品明细
  488. addProductHandle () {
  489. this.productListVisible = true
  490. this.$nextTick(() => {
  491. this.$refs.productList.init(2)
  492. })
  493. },
  494. // 编辑产品项
  495. updateProductHandle (row) {
  496. this.productListVisible = true
  497. this.$nextTick(() => {
  498. this.$refs.productList.init(2, row, this.addType)
  499. })
  500. },
  501. // 删除产品项
  502. deleteProductHandle (recordId) {
  503. this.productDetails.splice(this.productDetails.findIndex((item) => item.recordId === recordId), 1)
  504. },
  505. // 添加任务工单
  506. addWorkItemHandle () {
  507. this.worderListVisible = true
  508. this.$nextTick(() => {
  509. this.$refs.worderList.init()
  510. })
  511. },
  512. // 编辑产品项
  513. updateWorkItemHandle (row) {
  514. this.worderListVisible = true
  515. this.$nextTick(() => {
  516. this.$refs.worderList.init(row.recordId, row)
  517. })
  518. },
  519. // 删除产品项
  520. deleteWorkItemHandle (recordId) {
  521. this.workInfoDetails.splice(this.workInfoDetails.findIndex((item) => item.recordId === recordId), 1)
  522. },
  523. // 预览
  524. previewFile (fileName, url) {
  525. this.previewVisible = true
  526. this.$nextTick(() => {
  527. this.$refs.preview.init(fileName, url)
  528. })
  529. }
  530. }
  531. }
  532. </script>
  533. <style scoped>
  534. </style>