scheduling-outsource.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <!-- 排产、委外 -->
  2. <template>
  3. <div>
  4. <div class="my-title">委外</div>
  5. <!-- 表单 -->
  6. <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
  7. <el-row class="my-row">
  8. <el-col :span="8">
  9. <el-form-item label="委外编码" prop="purchaseCode">
  10. <el-input v-model="dataForm.purchaseCode" disabled placeholder="委外编码由系统生成"></el-input>
  11. </el-form-item>
  12. </el-col>
  13. <el-col :span="16">
  14. <el-form-item label="付款方式" prop="payType">
  15. <el-radio-group v-model="dataForm.payType">
  16. <el-radio :label='"1"'>对公转账</el-radio>
  17. <el-radio :label='"2"'>先行垫付</el-radio>
  18. <el-radio :label='"3"'>财务预支</el-radio>
  19. </el-radio-group>
  20. </el-form-item>
  21. </el-col>
  22. </el-row>
  23. <el-row class="my-row">
  24. <el-col :span="8">
  25. <el-form-item label="委外类别" prop="commissionType">
  26. <el-select
  27. v-model="dataForm.commissionType"
  28. remote
  29. placeholder="请选择">
  30. <el-option
  31. v-for="item in optionsType"
  32. :key="item.code"
  33. :label="item.value"
  34. :value="item.code">
  35. </el-option>
  36. </el-select>
  37. </el-form-item>
  38. </el-col>
  39. </el-row>
  40. <div class="title"><span style="color: red">*</span> 委外物料明细</div>
  41. <el-row class="my-row">
  42. <el-table
  43. :data="productDetails"
  44. border
  45. style="width: 100%;">
  46. <el-table-column
  47. label="序号"
  48. type="index"
  49. width="50"
  50. align="center">
  51. </el-table-column>
  52. <el-table-column
  53. prop="detailId"
  54. label="ID"
  55. v-if="false">
  56. </el-table-column>
  57. <el-table-column
  58. prop="productName"
  59. header-align="center"
  60. align="center"
  61. width="140"
  62. :show-tooltip-when-overflow="true"
  63. label="物料名称">
  64. </el-table-column>
  65. <el-table-column
  66. prop="prodCode"
  67. header-align="center"
  68. align="center"
  69. width="120"
  70. :show-tooltip-when-overflow="true"
  71. label="物料编号">
  72. </el-table-column>
  73. <el-table-column
  74. prop="productSpec"
  75. header-align="center"
  76. align="center"
  77. width="120"
  78. :show-tooltip-when-overflow="true"
  79. label="型号及规格">
  80. </el-table-column>
  81. <el-table-column
  82. prop="cnt"
  83. header-align="center"
  84. align="center"
  85. label="数量">
  86. </el-table-column>
  87. <el-table-column
  88. prop="unitName"
  89. header-align="center"
  90. align="center"
  91. label="单位">
  92. </el-table-column>
  93. <el-table-column
  94. prop="deadline"
  95. header-align="center"
  96. align="center"
  97. width="140"
  98. :show-tooltip-when-overflow="true"
  99. label="委外期限">
  100. </el-table-column>
  101. <el-table-column
  102. prop="batchNumber"
  103. header-align="center"
  104. align="center"
  105. width="120"
  106. :show-tooltip-when-overflow="true"
  107. label="批次号">
  108. </el-table-column>
  109. <el-table-column
  110. prop="specificationExplian"
  111. header-align="center"
  112. align="center"
  113. width="120"
  114. :show-tooltip-when-overflow="true"
  115. label="要求说明">
  116. </el-table-column>
  117. <el-table-column
  118. prop="arrivedTime"
  119. header-align="center"
  120. align="center"
  121. width="140"
  122. :show-tooltip-when-overflow="true"
  123. label="到料时间">
  124. </el-table-column>
  125. <el-table-column
  126. prop="qualifiedCnt"
  127. header-align="center"
  128. align="center"
  129. label="合格数量">
  130. </el-table-column>
  131. <!-- <el-table-column-->
  132. <!-- prop="technologyFile"-->
  133. <!-- header-align="center"-->
  134. <!-- align="center"-->
  135. <!-- width="160"-->
  136. <!-- :show-tooltip-when-overflow="true"-->
  137. <!-- label="工艺文件">-->
  138. <!-- </el-table-column>-->
  139. <el-table-column
  140. prop="attachList"
  141. header-align="center"
  142. align="center"
  143. min-width="160"
  144. label="附件">
  145. <template slot-scope="scope">
  146. <div v-for="(item, index) in scope.row.attachList" style="display: inline">
  147. <span v-if="index > 0">,</span>
  148. <a :key="item.fileName + index" type="primary" href="#" @click="previewFile(item.fileName, item.url)">{{ item.fileName }}</a>
  149. </div>
  150. </template>
  151. </el-table-column>
  152. <el-table-column
  153. prop="price"
  154. header-align="center"
  155. align="center"
  156. min-width="100"
  157. label="不含税单价">
  158. </el-table-column>
  159. <el-table-column
  160. prop="taxPrice"
  161. header-align="center"
  162. align="center"
  163. label="含税单价">
  164. </el-table-column>
  165. <el-table-column
  166. prop="taxAmount"
  167. header-align="center"
  168. align="center"
  169. label="含税总价">
  170. </el-table-column>
  171. <el-table-column
  172. prop="taxRate"
  173. header-align="center"
  174. align="center"
  175. :formatter="formatPercent"
  176. label="税率">
  177. </el-table-column>
  178. <el-table-column
  179. prop="notes"
  180. header-align="center"
  181. align="center"
  182. label="备注">
  183. </el-table-column>
  184. <el-table-column
  185. fixed="right"
  186. header-align="center"
  187. align="center"
  188. width="80"
  189. label="操作">
  190. <template slot-scope="scope">
  191. <el-button type="text" size="small" @click="addProductHandle(scope.row)">编辑</el-button>
  192. <!-- <el-button style="color: red" type="text" size="small" @click="deleteProductHandle(scope.row.detailId)">删除</el-button>-->
  193. </template>
  194. </el-table-column>
  195. </el-table>
  196. </el-row>
  197. <el-row style="margin-top: 20px">
  198. <span>合计(含税): {{totalAmount}}</span>
  199. </el-row>
  200. <!-- <el-row style="text-align: center; margin-top: 10px;">-->
  201. <!-- <el-button type="primary" icon="el-icon-plus" @click="addMaterial"></el-button>-->
  202. <!-- </el-row>-->
  203. </el-form>
  204. <span slot="footer" class="dialog-footer">
  205. <el-button @click="onChose">取消</el-button>
  206. <el-button type="primary" @click="dataFormSubmit()" v-reClick>确定</el-button>
  207. </span>
  208. <!-- 新增物品 -->
  209. <Add v-show="addProductVisible" ref="comAddProduct" @addItem="addProductCallback"/>
  210. <!-- 文件预览 -->
  211. <preview-component v-if="previewVisible" ref="preview"/>
  212. </div>
  213. </template>
  214. <script>
  215. import { getOutsourceDetail, getOutsourceDetailByScheduleId } from '@/api/sale'
  216. import { getDictList } from '@/api/dict'
  217. import Add from '../sale/edit-product'
  218. import ApproveComponent from '../common/approve-component'
  219. import PreviewComponent from '../common/preview-component'
  220. export default {
  221. name: 'scheduling-outsource',
  222. components: {
  223. PreviewComponent,
  224. ApproveComponent,
  225. Add
  226. },
  227. data () {
  228. return {
  229. id: 0,
  230. dataForm: {},
  231. dataRule: {
  232. payType: [{ required: true, message: '请选择付款方式', trigger: 'change' }],
  233. commissionType: [{ required: true, message: '请选择委外类别', trigger: 'change' }]
  234. },
  235. optionsType: [],
  236. totalAmount: 0,
  237. addProductVisible: false,
  238. productDetails: [],
  239. prodProductionIds: [], // 排产ID的集合
  240. previewVisible: false
  241. }
  242. },
  243. methods: {
  244. onChose () {
  245. this.$emit('onChose')
  246. },
  247. async init (id, prodProductionIds) {
  248. if (prodProductionIds) {
  249. this.prodProductionIds = prodProductionIds
  250. }
  251. this.productDetails = []
  252. this.dataForm = {
  253. payType: '1'
  254. }
  255. this.id = id || 0
  256. // 获取委外类别列表
  257. this.getType()
  258. // 详情
  259. if (!id) return
  260. if (this.prodProductionIds.length > 0) {
  261. await getOutsourceDetailByScheduleId({'prodProductionIds': this.prodProductionIds}).then(({data}) => {
  262. if (data && data.code === '200' && data.data) {
  263. this.productDetails = data.data
  264. if (this.productDetails && this.productDetails.length > 0) {
  265. this.productDetails.forEach((item) => {
  266. item.detailId = Math.round(Math.random() * 1000000)
  267. })
  268. this.calTotal()
  269. }
  270. }
  271. })
  272. } else {
  273. await getOutsourceDetail(this.id).then(({data}) => {
  274. if (data && data.code === '200' && data.data) {
  275. this.dataForm = data.data
  276. this.productDetails = data.data.purCommissionDetails
  277. if (this.productDetails && this.productDetails.length > 0) {
  278. this.productDetails.forEach((item) => {
  279. item.detailId = Math.round(Math.random() * 1000000)
  280. })
  281. this.calTotal()
  282. }
  283. }
  284. })
  285. }
  286. },
  287. // 获取类别
  288. getType () {
  289. getDictList({type: 'commission_type'}).then(({data}) => {
  290. if (data) {
  291. this.optionsType = data
  292. }
  293. })
  294. },
  295. validateField (type) {
  296. this.$refs.dataForm.validateField(type)
  297. },
  298. // 表单提交
  299. dataFormSubmit () {
  300. this.$refs['dataForm'].validate((valid) => {
  301. if (valid) {
  302. let action = ''
  303. if (this.prodProductionIds.length > 0) {
  304. action = `/biz-service/purCommDetail/save`
  305. } else {
  306. action = `/biz-service/purCommDetail/${!this.id ? 'save' : 'update'}`
  307. }
  308. // 物料明细
  309. this.$http({
  310. url: this.$http.adornUrl(action),
  311. method: 'post',
  312. data: this.$http.adornData({
  313. ...this.dataForm,
  314. purCommissionDetails: this.productDetails,
  315. applierId: this.$store.state.user.id,
  316. orgId: this.$store.state.user.orgId
  317. })
  318. }).then(({data}) => {
  319. if (data && data.code === '200') {
  320. this.$message({
  321. message: '操作成功',
  322. type: 'success',
  323. duration: 1500,
  324. onClose: () => {
  325. this.onChose()
  326. this.$emit('refreshDataList')
  327. }
  328. })
  329. } else {
  330. this.$message.error(data.msg)
  331. }
  332. })
  333. }
  334. })
  335. },
  336. addMaterial () {
  337. this.addProductVisible = true
  338. this.$nextTick(() => {
  339. this.$refs.comAddProduct.init()
  340. })
  341. },
  342. addProductHandle (row) {
  343. this.addProductVisible = true
  344. this.$nextTick(() => {
  345. this.$refs.comAddProduct.init(row.detailId, row)
  346. })
  347. },
  348. deleteProductHandle (detailId) {
  349. if (!detailId) return
  350. this.productDetails.splice(this.productDetails.findIndex((item) => item.detailId === detailId), 1)
  351. this.calTotal()
  352. },
  353. addProductCallback (data) {
  354. if (!data) return
  355. this.addProductVisible = false
  356. let i = this.productDetails.findIndex((item) => item.detailId === data.detailId)
  357. if (i > -1) {
  358. this.productDetails.splice(i, 1)
  359. }
  360. this.productDetails.push(data)
  361. this.calTotal()
  362. },
  363. calTotal () {
  364. let total = 0
  365. if (this.productDetails) {
  366. this.productDetails.forEach((item) => {
  367. total += item.taxAmount ? Number(item.taxAmount) : 0
  368. })
  369. }
  370. this.totalAmount = total
  371. },
  372. // 百分比
  373. formatPercent (row) {
  374. if (!row.taxRate) return ''
  375. let str = (Number(row.taxRate * 100)).toFixed(0)
  376. str += '%'
  377. return str
  378. },
  379. // 预览
  380. previewFile (fileName, url) {
  381. this.previewVisible = true
  382. this.$nextTick(() => {
  383. this.$refs.preview.init(fileName, url)
  384. })
  385. }
  386. }
  387. }
  388. </script>
  389. <style scoped>
  390. </style>