add.vue 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951
  1. <template>
  2. <div>
  3. <el-card class="box-card">
  4. <div style="padding: 8px; text-align: center" v-if="formData.data.code || formData.data.wlnCode">
  5. <span style="font-size: 18px; font-weight: 700">{{ formData.data.code }} </span>
  6. <span style="font-size: 18px; font-weight: 700" v-if="formData.data.wlnCode"> ({{ formData.data.wlnCode }})</span>
  7. </div>
  8. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
  9. <template #deliveryAddress>
  10. <div style="width: 100%">
  11. <el-row>
  12. <el-col :span="3">
  13. <el-form-item label-width="0" prop="province" style="width: 100%">
  14. <el-input v-model="formData.data.province" placeholder="请输入省" />
  15. </el-form-item>
  16. </el-col>
  17. <el-col :span="3">
  18. <el-form-item label-width="0" prop="city" style="width: 100%">
  19. <el-input v-model="formData.data.city" placeholder="请输入市" />
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="3">
  23. <el-form-item label-width="0" prop="county" style="width: 100%">
  24. <el-input v-model="formData.data.county" placeholder="请输入区/县" />
  25. </el-form-item>
  26. </el-col>
  27. <el-col :span="11">
  28. <el-form-item label-width="0" prop="detailedAddress" style="width: 100%">
  29. <el-input v-model="formData.data.detailedAddress" placeholder="请输入详细地址" />
  30. </el-form-item>
  31. </el-col>
  32. <el-col :span="4">
  33. <el-form-item label-width="0" prop="postcode" style="width: 100%">
  34. <el-input v-model="formData.data.postcode" placeholder="请输入邮编" />
  35. </el-form-item>
  36. </el-col>
  37. </el-row>
  38. </div>
  39. </template>
  40. <template #consignee>
  41. <div style="width: 100%">
  42. <el-row>
  43. <el-col :span="6">
  44. <el-form-item label-width="0" prop="consignee" style="width: 100%">
  45. <el-input v-model="formData.data.consignee" placeholder="请输入联系人" />
  46. </el-form-item>
  47. </el-col>
  48. <el-col :span="6">
  49. <el-form-item label-width="0" prop="consigneeNumber" style="width: 100%">
  50. <el-input v-model="formData.data.consigneeNumber" placeholder="请输入联系电话" />
  51. </el-form-item>
  52. </el-col>
  53. <el-col :span="6">
  54. <el-form-item label-width="0" prop="departmentId" style="width: 100%">
  55. <el-select v-model="formData.data.departmentId" placeholder="请选择事业部" clearable style="width: 100%">
  56. <el-option v-for="item in departmentList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  57. </el-select>
  58. </el-form-item>
  59. </el-col>
  60. </el-row>
  61. </div>
  62. </template>
  63. <template #orderSkuList>
  64. <div style="width: 100%; padding: 0 20px">
  65. <div style="margin-bottom: 10px" v-if="!(route.query && route.query.detailId)">
  66. <el-button type="primary" size="small" @click="clickAddProduct()">选择产品</el-button>
  67. </div>
  68. <el-collapse v-model="activeNames">
  69. <div v-for="(item, index) in formData.data.orderSkuList" :key="index" style="margin-bottom: 20px">
  70. <div style="border: 1px solid #edf0f5">
  71. <el-table :data="[item]" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
  72. <el-table-column label="产品" width="300">
  73. <template #default="{ row }">
  74. <div style="width: 100%">
  75. <div style="line-height: 35px">
  76. <span style="color: black; font-weight: 700">商品名称: </span>
  77. <span>{{ item.wlnSkuName }}</span>
  78. </div>
  79. <div style="line-height: 35px">
  80. <span style="color: black; font-weight: 700">品号: </span>
  81. <span>{{ item.code }}</span>
  82. </div>
  83. <div style="line-height: 35px; word-break: break-all">
  84. <span style="color: black; font-weight: 700">品名: </span>
  85. <span>{{ item.name }}</span>
  86. </div>
  87. <div style="line-height: 35px; display: flex">
  88. <span style="width: 37px; color: black; font-weight: 700">数量: </span>
  89. <el-form-item
  90. :prop="'orderSkuList.' + index + '.quantity'"
  91. :rules="rules.quantity"
  92. :inline-message="true"
  93. style="width: calc(100% - 37px)">
  94. <el-input-number
  95. onmousewheel="return false;"
  96. v-model="row.quantity"
  97. placeholder="数量"
  98. style="width: 100%"
  99. :controls="false"
  100. :min="0"
  101. :precision="0"
  102. @change="changeQuantity(index)" />
  103. </el-form-item>
  104. </div>
  105. <div style="line-height: 35px">
  106. <span style="color: black; font-weight: 700">加工费: </span>
  107. <span>{{ item.customProcessingFee }}</span>
  108. </div>
  109. <div style="line-height: 35px">
  110. <span style="color: black; font-weight: 700">代发费: </span>
  111. <span>{{ item.lssueFee }}</span>
  112. </div>
  113. <div style="line-height: 35px">
  114. <span style="color: black; font-weight: 700">快递包材费: </span>
  115. <span>{{ item.deliveryMaterialsFee }}</span>
  116. </div>
  117. <div style="line-height: 35px">
  118. <span style="color: black; font-weight: 700">包装人工费: </span>
  119. <span>{{ item.packingLabor }}</span>
  120. </div>
  121. <div style="line-height: 35px">
  122. <span style="color: black; font-weight: 700">单价: </span>
  123. <span>{{ item.unitPrice }}</span>
  124. </div>
  125. <div style="line-height: 35px">
  126. <span style="color: black; font-weight: 700">小计: </span>
  127. <span>{{ item.subtotal }}</span>
  128. </div>
  129. <div style="line-height: 35px">
  130. <span style="width: 37px; color: black; font-weight: 700">打印: </span>
  131. <el-form-item
  132. :prop="'orderSkuList.' + index + '.printType'"
  133. :rules="rules.printType"
  134. :inline-message="true"
  135. style="width: calc(100% - 37px)">
  136. <el-radio-group v-model="item.printType">
  137. <el-radio v-for="(itemType, index) in printType" :key="index" :label="itemType.dictKey">{{ itemType.dictValue }}</el-radio>
  138. </el-radio-group>
  139. </el-form-item>
  140. </div>
  141. </div>
  142. </template>
  143. </el-table-column>
  144. <el-table-column label="图稿(设计图)" width="180">
  145. <template #default="{ row }">
  146. <el-form-item :prop="'orderSkuList.' + index + '.blueprint'">
  147. <el-upload
  148. class="avatar-uploader"
  149. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  150. :data="uploadProductData"
  151. :show-file-list="false"
  152. :on-success="
  153. (response, uploadFile) => {
  154. return handleProductSuccess(uploadFile, index);
  155. }
  156. "
  157. :before-upload="uploadProductFile">
  158. <el-image v-if="row.blueprint" :src="row.blueprint" fit="scale-down" class="avatar" />
  159. <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
  160. </el-upload>
  161. </el-form-item>
  162. </template>
  163. </el-table-column>
  164. <el-table-column label="图稿(生产文件)" width="320">
  165. <template #default="{ row }">
  166. <div style="color: black; line-height: 35px">共享文件夹路径(点击下方链接并上传文件):</div>
  167. <div v-if="row.productionDocument">
  168. <a style="color: #409eff; cursor: pointer; word-break: break-all" @click="openFile(row.productionDocument)">
  169. {{ row.productionDocument }}
  170. </a>
  171. </div>
  172. <el-upload
  173. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  174. :data="uploadData"
  175. :show-file-list="false"
  176. :before-upload="beforeUpload"
  177. :on-success="
  178. (response, uploadFile) => {
  179. return handleSuccess(uploadFile, index);
  180. }
  181. ">
  182. <el-button style="background: #20b2aa; color: #fff; border: 1px solid #20b2aa">上传</el-button>
  183. </el-upload>
  184. </template>
  185. </el-table-column>
  186. <el-table-column label="包材配件/单品" min-width="400">
  187. <template #default="{ row }">
  188. <div style="width: 100%">
  189. <div style="margin-bottom: 10px" v-if="!(route.query && route.query.detailId)">
  190. <el-button type="primary" @click="clickPackingFittings(index)">选择包材配件</el-button>
  191. </div>
  192. <el-table :data="row.orderSkuBomList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
  193. <el-table-column label="单价¥" width="120">
  194. <template #default="props">
  195. <div>
  196. <span>{{ moneyFormat(props.row.unitPrice, 2) }}</span>
  197. </div>
  198. </template>
  199. </el-table-column>
  200. <el-table-column label="数量" width="100">
  201. <template #default="props">
  202. <el-form-item
  203. :prop="'orderSkuList.' + index + '.orderSkuBomList.' + props.$index + '.quantity'"
  204. :rules="rules.quantity"
  205. :inline-message="true"
  206. style="width: 100%">
  207. <el-input-number
  208. onmousewheel="return false;"
  209. v-model="props.row.quantity"
  210. placeholder="数量"
  211. style="width: 100%"
  212. :controls="false"
  213. :min="0"
  214. @change="changeBOMQuantity(index)" />
  215. </el-form-item>
  216. </template>
  217. </el-table-column>
  218. <el-table-column label="名称" prop="bomSpecName" min-width="150" />
  219. <el-table-column label="总量" prop="allQuantity" width="80" />
  220. <el-table-column label="小计¥" width="100">
  221. <template #default="props">
  222. {{ moneyFormat(props.row.allUnitPrice, 2) }}
  223. </template>
  224. </el-table-column>
  225. <el-table-column label="操作" align="center" fixed="right" width="60" v-if="!(route.query && route.query.detailId)">
  226. <template #default="props">
  227. <el-button type="danger" @click="clickDeletePackingFittings(index, props.$index)" text>删除</el-button>
  228. </template>
  229. </el-table-column>
  230. </el-table>
  231. </div>
  232. </template>
  233. </el-table-column>
  234. <el-table-column label="操作" align="center" fixed="right" width="60" v-if="!(route.query && route.query.detailId)">
  235. <template #default="{}">
  236. <el-button type="danger" @click="clickDelete(index)" text>删除</el-button>
  237. </template>
  238. </el-table-column>
  239. </el-table>
  240. <el-collapse-item :name="index">
  241. <template #title>
  242. <span>包装</span>
  243. </template>
  244. <div style="display: flex; padding: 8px 10px 0px">
  245. <div style="flex: 1; padding: 0px 10px">
  246. <div>包装要求:</div>
  247. <div v-if="route.query && route.query.detailId">
  248. <div v-html="getStyle(item.packageRemark)"></div>
  249. </div>
  250. <Editor
  251. v-else
  252. :value="item.packageRemark"
  253. @updateValue="
  254. (val) => {
  255. return updatePackageRemark(val, index);
  256. }
  257. "
  258. :ref="'editor_' + index" />
  259. </div>
  260. </div>
  261. </el-collapse-item>
  262. </div>
  263. </div>
  264. </el-collapse>
  265. </div>
  266. </template>
  267. <template #deliveryTime>
  268. <div style="width: 100%">
  269. <el-date-picker
  270. v-model="formData.data.deliveryTime"
  271. type="datetime"
  272. placeholder="请选择交货日期"
  273. value-format="YYYY-MM-DD HH:mm:ss"
  274. style="width: 100%" />
  275. </div>
  276. </template>
  277. <template #totalMonet>
  278. <div style="width: 100%; margin-left: 30px">
  279. <div>
  280. <span style="font-weight: 700; color: #6c88f1">产品总金额: ¥{{ moneyFormat(formData.data.productTotalAmount, 2) }}</span>
  281. <span style="font-weight: 700; color: #6c88f1; margin-left: 40px">定制加工费: ¥{{ moneyFormat(formData.data.customProcessingFee, 2) }}</span>
  282. <span style="font-weight: 700; color: #6c88f1; margin-left: 40px">代发费: ¥{{ moneyFormat(formData.data.lssueFee, 2) }}</span>
  283. <span style="font-weight: 700; color: #6c88f1; margin-left: 40px">快递包材费: ¥{{ moneyFormat(formData.data.deliveryMaterialsFee, 2) }}</span>
  284. <span style="font-weight: 700; color: #6c88f1; margin-left: 40px">包装人工费: ¥{{ moneyFormat(formData.data.packingLabor, 2) }}</span>
  285. <span style="font-weight: 700; color: #6c88f1; margin-left: 40px">包材费: ¥{{ moneyFormat(formData.data.packagingMaterialCost, 2) }}</span>
  286. </div>
  287. <div style="padding: 8px 0 0 0">
  288. <span style="font-weight: 700; color: red">订单总金额(含税): ¥{{ moneyFormat(formData.data.totalAmount, 2) }}</span>
  289. </div>
  290. </div>
  291. </template>
  292. <!-- <template #attachments>
  293. <div style="width: 100%">
  294. <el-upload
  295. v-model:fileList="fileList"
  296. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  297. :data="uploadData"
  298. multiple
  299. :before-upload="beforeUpload"
  300. :on-success="handleSuccess"
  301. :on-preview="onPreviewFile">
  302. <el-button style="background: #20b2aa; color: #fff; border: 1px solid #20b2aa">上传</el-button>
  303. </el-upload>
  304. </div>
  305. </template> -->
  306. <template #remark>
  307. <div style="width: 100%">
  308. <div v-if="route.query && route.query.detailId">
  309. <div v-html="getStyle(formData.data.remark)"></div>
  310. </div>
  311. <Editor v-else :value="formData.data.remark" @updateValue="updateValue" ref="editor" />
  312. </div>
  313. </template>
  314. </byForm>
  315. <div style="width: 100%; text-align: center; margin: 10px">
  316. <el-button @click="clickCancel()" v-if="route.query && route.query.detailId" size="large">关 闭</el-button>
  317. <el-button @click="clickCancel()" v-if="!(route.query && route.query.detailId)" size="large">取 消</el-button>
  318. <el-button @click="submitForm('0')" v-if="!(route.query && route.query.detailId) && !route.query.status" size="large" v-preReClick>暂 存</el-button>
  319. <el-button type="primary" @click="submitForm('10')" v-if="!(route.query && route.query.detailId)" size="large" v-preReClick>确 定</el-button>
  320. </div>
  321. </el-card>
  322. <el-dialog title="选择产品" v-if="openProduct" v-model="openProduct" width="90%">
  323. <SelectProduct :selectStatus="true" @selectProduct="selectProduct"></SelectProduct>
  324. <template #footer>
  325. <el-button @click="openProduct = false" size="large">关 闭</el-button>
  326. </template>
  327. </el-dialog>
  328. <el-dialog title="选择包材配件" v-if="openPackingFittings" v-model="openPackingFittings" width="90%">
  329. <SelectBOM :selectStatus="true" :bomClassifyIdList="[2, 3]" @selectBOM="selectPackingFittings"></SelectBOM>
  330. <template #footer>
  331. <el-button @click="openPackingFittings = false" size="large">关 闭</el-button>
  332. </template>
  333. </el-dialog>
  334. </div>
  335. </template>
  336. <script setup>
  337. import byForm from "@/components/byForm/index";
  338. import { ElMessage } from "element-plus";
  339. import Editor from "@/components/Editor/index.vue";
  340. import { useRouter, useRoute } from "vue-router";
  341. import SelectProduct from "@/views/group/product/management/index";
  342. import SelectBOM from "@/views/group/BOM/management/index";
  343. import useTagsViewStore from "@/store/modules/tagsView";
  344. const { proxy } = getCurrentInstance();
  345. const router = useRouter();
  346. const route = useRoute();
  347. const submit = ref(null);
  348. const departmentList = ref([]);
  349. const activeNames = ref([]);
  350. const formOption = reactive({
  351. inline: true,
  352. labelWidth: "120px",
  353. itemWidth: 100,
  354. rules: [],
  355. labelPosition: "right",
  356. });
  357. const formData = reactive({
  358. data: {
  359. remark: "",
  360. fileList: [],
  361. orderSkuList: [],
  362. },
  363. });
  364. const formConfig = computed(() => {
  365. return [
  366. route.query && route.query.detailId
  367. ? {}
  368. : {
  369. type: "title",
  370. title: "地址",
  371. label: "",
  372. },
  373. route.query && route.query.detailId
  374. ? {}
  375. : {
  376. type: "slot",
  377. slotName: "deliveryAddress",
  378. label: "收货地址",
  379. },
  380. route.query && route.query.detailId
  381. ? {}
  382. : {
  383. type: "slot",
  384. slotName: "consignee",
  385. label: "收货人",
  386. },
  387. {
  388. type: "title",
  389. title: "产品",
  390. label: "",
  391. },
  392. {
  393. type: "slot",
  394. prop: "orderSkuList",
  395. slotName: "orderSkuList",
  396. },
  397. {
  398. type: "title",
  399. title: "贸易",
  400. label: "",
  401. },
  402. {
  403. type: "slot",
  404. prop: "deliveryTime",
  405. slotName: "deliveryTime",
  406. label: "交货时间",
  407. itemWidth: 25,
  408. },
  409. {
  410. type: "select",
  411. label: "选择快递",
  412. prop: "expressDeliveryId",
  413. data: [],
  414. itemWidth: 25,
  415. clearable: true,
  416. },
  417. {
  418. type: "select",
  419. label: "电商平台",
  420. prop: "commercePlatform",
  421. data: proxy.useUserStore().allDict["commerce_platform"],
  422. itemWidth: 25,
  423. clearable: true,
  424. },
  425. {
  426. type: "title",
  427. title: "总计",
  428. label: "",
  429. },
  430. {
  431. type: "slot",
  432. prop: "totalMonet",
  433. slotName: "totalMonet",
  434. },
  435. // {
  436. // type: "title",
  437. // title: "附件",
  438. // label: "",
  439. // },
  440. // {
  441. // type: "slot",
  442. // slotName: "attachments",
  443. // label: "附件",
  444. // },
  445. {
  446. type: "title",
  447. title: "订单备注",
  448. label: "",
  449. },
  450. {
  451. type: "slot",
  452. slotName: "remark",
  453. },
  454. ];
  455. });
  456. const rules = ref({
  457. province: [{ required: true, message: "请输入省", trigger: "blur" }],
  458. detailedAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  459. consignee: [{ required: true, message: "请输入联系人", trigger: "blur" }],
  460. consigneeNumber: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
  461. deliveryTime: [{ required: true, message: "请选择交货时间", trigger: "change" }],
  462. // expressDeliveryId: [{ required: true, message: "请选择快递", trigger: "change" }],
  463. commercePlatform: [{ required: true, message: "请选择电商平台", trigger: "change" }],
  464. quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
  465. });
  466. const getDemandData = () => {
  467. proxy.post("/department/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  468. if (res.rows && res.rows.length > 0) {
  469. departmentList.value = res.rows.map((item) => {
  470. return {
  471. dictKey: item.id,
  472. dictValue: item.name,
  473. };
  474. });
  475. }
  476. });
  477. };
  478. getDemandData();
  479. const uploadProductData = ref({});
  480. const uploadProductFile = async (file) => {
  481. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  482. uploadProductData.value = res.uploadBody;
  483. file.id = res.id;
  484. file.fileName = res.fileName;
  485. file.fileUrl = res.fileUrl;
  486. return true;
  487. };
  488. const handleProductSuccess = (uploadFile, index) => {
  489. formData.data.orderSkuList[index].blueprint = uploadFile.raw.fileUrl;
  490. };
  491. const uploadData = ref({});
  492. const fileList = ref([]);
  493. const beforeUpload = async (file) => {
  494. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  495. uploadData.value = res.uploadBody;
  496. file.id = res.id;
  497. file.fileName = res.fileName;
  498. file.fileUrl = res.fileUrl;
  499. file.uploadState = true;
  500. return true;
  501. };
  502. const handleSuccess = (uploadFile, index) => {
  503. formData.data.orderSkuList[index].productionDocument = uploadFile.raw.fileUrl;
  504. };
  505. const onPreviewFile = (file) => {
  506. window.open(file.raw.fileUrl, "_blank");
  507. };
  508. const openFile = (path) => {
  509. window.open(path);
  510. };
  511. const updatePackageRemark = (val, index) => {
  512. formData.data.orderSkuList[index].packageRemark = val;
  513. };
  514. const clickDelete = (index) => {
  515. formData.data.orderSkuList.splice(index, 1);
  516. calculatedAmount();
  517. };
  518. const updateValue = (val) => {
  519. formData.data.remark = val;
  520. };
  521. const submitForm = (status) => {
  522. submit.value.handleSubmit(() => {
  523. if (formData.data.orderSkuList && formData.data.orderSkuList.length > 0) {
  524. if (fileList.value && fileList.value.length > 0) {
  525. for (let i = 0; i < fileList.value.length; i++) {
  526. if (fileList.value[i].raw.uploadState) {
  527. return ElMessage("文件上传中,请稍后提交");
  528. }
  529. }
  530. formData.data.fileList = fileList.value.map((item) => {
  531. return {
  532. id: item.raw.id,
  533. fileName: item.raw.fileName,
  534. fileUrl: item.raw.fileUrl,
  535. };
  536. });
  537. } else {
  538. formData.data.fileList = [];
  539. }
  540. if (route.query.status) {
  541. for (let i = 0; i < formData.data.orderSkuList.length; i++) {
  542. if (!formData.data.orderSkuList[i].blueprint) {
  543. return ElMessage("请上传设计图");
  544. }
  545. if (!formData.data.orderSkuList[i].productionDocument) {
  546. return ElMessage("请上传生产文件");
  547. }
  548. }
  549. formData.data.status = route.query.status;
  550. } else {
  551. formData.data.status = status;
  552. }
  553. let type = "add";
  554. if (formData.data.id) {
  555. type = "edit";
  556. }
  557. proxy.post("/orderInfo/" + type, formData.data).then(() => {
  558. ElMessage({
  559. message: type == "add" ? "添加成功" : "编辑成功",
  560. type: "success",
  561. });
  562. clickCancel();
  563. });
  564. } else {
  565. return ElMessage("请添加产品");
  566. }
  567. });
  568. };
  569. const clickCancel = () => {
  570. const useTagsStore = useTagsViewStore();
  571. useTagsStore.delVisitedView(router.currentRoute.value);
  572. if (route.query && route.query.orderInquiry) {
  573. router.replace({
  574. path: "/production/schedule/order-inquiry",
  575. });
  576. } else {
  577. router.replace({
  578. path: "/subsidiary/order/subsidiary-order-management",
  579. });
  580. }
  581. };
  582. onMounted(() => {
  583. if (route.query && (route.query.id || route.query.detailId)) {
  584. useTagsViewStore().visitedViews = useTagsViewStore().visitedViews.map((item) => {
  585. if (item.query && item.query.random === route.query.random) {
  586. return {
  587. ...item,
  588. name: route.query.text,
  589. title: route.query.text,
  590. };
  591. } else {
  592. return {
  593. ...item,
  594. };
  595. }
  596. });
  597. getOrderDetail({ id: route.query.id || route.query.detailId });
  598. }
  599. });
  600. const getOrderDetail = (parameter) => {
  601. proxy.post("/orderInfo/detail", parameter).then((res) => {
  602. formData.data = res;
  603. if (route.query.id) {
  604. proxy.$refs.editor.changeHtml(formData.data.remark);
  605. }
  606. if (route.query.detailId) {
  607. let allIndex = [];
  608. for (let i = 0; i < formData.data.orderSkuList.length; i++) {
  609. allIndex.push(i);
  610. }
  611. activeNames.value = allIndex;
  612. formOption.disabled = true;
  613. }
  614. if (formData.data.orderSkuList && formData.data.orderSkuList.length > 0) {
  615. for (let i = 0; i < formData.data.orderSkuList.length; i++) {
  616. let subtotal = 0;
  617. let packagingMaterialCost = 0;
  618. if (formData.data.orderSkuList[i].quantity) {
  619. subtotal = Number(
  620. Math.round(
  621. (formData.data.orderSkuList[i].customProcessingFee +
  622. formData.data.orderSkuList[i].deliveryMaterialsFee +
  623. formData.data.orderSkuList[i].lssueFee +
  624. formData.data.orderSkuList[i].packingLabor +
  625. formData.data.orderSkuList[i].unitPrice) *
  626. formData.data.orderSkuList[i].quantity *
  627. 100
  628. ) / 100
  629. );
  630. if (formData.data.orderSkuList[i].orderSkuBomList && formData.data.orderSkuList[i].orderSkuBomList.length > 0) {
  631. for (let j = 0; j < formData.data.orderSkuList[i].orderSkuBomList.length; j++) {
  632. let allQuantity = 0;
  633. let allUnitPrice = 0;
  634. if (formData.data.orderSkuList[i].orderSkuBomList[j].quantity) {
  635. allQuantity = Number(
  636. Math.round(formData.data.orderSkuList[i].orderSkuBomList[j].quantity * formData.data.orderSkuList[i].quantity * 100) / 100
  637. );
  638. if (formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice) {
  639. allUnitPrice = Number(
  640. Math.round(
  641. formData.data.orderSkuList[i].orderSkuBomList[j].quantity *
  642. formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice *
  643. formData.data.orderSkuList[i].quantity *
  644. 100
  645. ) / 100
  646. );
  647. packagingMaterialCost = Number(
  648. Math.round(
  649. (packagingMaterialCost +
  650. formData.data.orderSkuList[i].orderSkuBomList[j].quantity * formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice) *
  651. 100
  652. ) / 100
  653. );
  654. }
  655. }
  656. formData.data.orderSkuList[i].orderSkuBomList[j].allQuantity = allQuantity;
  657. formData.data.orderSkuList[i].orderSkuBomList[j].allUnitPrice = allUnitPrice;
  658. }
  659. }
  660. }
  661. formData.data.orderSkuList[i].subtotal = subtotal;
  662. formData.data.orderSkuList[i].packagingMaterialCost = packagingMaterialCost;
  663. }
  664. }
  665. let list = [res.id];
  666. if (res.orderSkuList && res.orderSkuList.length > 0) {
  667. list = list.concat(res.orderSkuList.map((item) => item.id));
  668. }
  669. proxy.post("/fileInfo/getList", { businessIdList: list }).then((fileObj) => {
  670. if (fileObj) {
  671. if (fileObj[res.id] && fileObj[res.id].length > 0) {
  672. fileList.value = fileObj[res.id].map((item) => {
  673. return {
  674. raw: item,
  675. name: item.fileName,
  676. url: item.fileUrl,
  677. };
  678. });
  679. }
  680. if (formData.data.orderSkuList && formData.data.orderSkuList.length > 0) {
  681. for (let i = 0; i < formData.data.orderSkuList.length; i++) {
  682. if (fileObj[formData.data.orderSkuList[i].id] && fileObj[formData.data.orderSkuList[i].id].length > 0) {
  683. formData.data.orderSkuList[i].blueprint = fileObj[formData.data.orderSkuList[i].id][0];
  684. }
  685. }
  686. }
  687. }
  688. });
  689. });
  690. };
  691. const getStyle = (text) => {
  692. if (text) {
  693. return text.replace(/\n|\r\n/g, "<br>");
  694. } else {
  695. return "";
  696. }
  697. };
  698. const openProduct = ref(false);
  699. const clickAddProduct = () => {
  700. openProduct.value = true;
  701. };
  702. const printType = ref([
  703. {
  704. dictKey: "1",
  705. dictValue: "单面",
  706. },
  707. {
  708. dictKey: "2",
  709. dictValue: "双面",
  710. },
  711. ]);
  712. const selectProduct = (row, bom) => {
  713. if (row.id) {
  714. let list = formData.data.orderSkuList.filter((item) => item.skuSpecId === row.id && item.bomSpecId === row.bomSpecId);
  715. if (list && list.length > 0) {
  716. return ElMessage("该产品已添加");
  717. }
  718. formData.data.orderSkuList.push({
  719. wlnSkuName: bom.name,
  720. skuId: row.skuId,
  721. code: row.code,
  722. name: row.name,
  723. skuSpecId: row.id,
  724. bomSpecId: row.bomSpecId,
  725. quantity: undefined,
  726. customProcessingFee: "",
  727. customProcessingType: "",
  728. lssueFee: "",
  729. deliveryMaterialsFee: "",
  730. packingLabor: "",
  731. unitPrice: "",
  732. printType: "1",
  733. packageRemark: "",
  734. subtotal: "",
  735. orderSkuBomList: [],
  736. });
  737. ElMessage({ message: "添加成功", type: "success" });
  738. } else {
  739. ElMessage("添加失败");
  740. }
  741. };
  742. const rowIndex = ref(null);
  743. const openPackingFittings = ref(false);
  744. const clickPackingFittings = (index) => {
  745. rowIndex.value = index;
  746. openPackingFittings.value = true;
  747. };
  748. const clickDeletePackingFittings = (index, indexTwo) => {
  749. formData.data.orderSkuList[index].orderSkuBomList.splice(indexTwo, 1);
  750. calculatedAmount();
  751. };
  752. const selectPackingFittings = (data) => {
  753. if (formData.data.orderSkuList[rowIndex.value].orderSkuBomList && formData.data.orderSkuList[rowIndex.value].orderSkuBomList.length > 0) {
  754. let list = formData.data.orderSkuList[rowIndex.value].orderSkuBomList.filter((item) => item.bomSpecId === data.id);
  755. if (list && list.length > 0) {
  756. return ElMessage("包材配件已添加");
  757. }
  758. formData.data.orderSkuList[rowIndex.value].orderSkuBomList.push({
  759. bomSpecId: data.id,
  760. unitPrice: data.costPrice,
  761. quantity: undefined,
  762. bomSpecName: data.name,
  763. allQuantity: 0,
  764. allUnitPrice: 0,
  765. });
  766. } else {
  767. formData.data.orderSkuList[rowIndex.value].orderSkuBomList = [
  768. {
  769. bomSpecId: data.id,
  770. unitPrice: data.costPrice,
  771. quantity: undefined,
  772. bomSpecName: data.name,
  773. allQuantity: 0,
  774. allUnitPrice: 0,
  775. },
  776. ];
  777. }
  778. ElMessage({ message: "添加成功", type: "success" });
  779. };
  780. const changeQuantity = (index) => {
  781. if (formData.data.orderSkuList[index].quantity) {
  782. proxy
  783. .post("/orderInfo/getSkuSpecPrice", { skuSpecId: formData.data.orderSkuList[index].skuSpecId, quantity: formData.data.orderSkuList[index].quantity })
  784. .then((res) => {
  785. formData.data.orderSkuList[index].customProcessingFee = res.customProcessingFee;
  786. formData.data.orderSkuList[index].customProcessingType = res.customProcessingType;
  787. formData.data.orderSkuList[index].deliveryMaterialsFee = res.deliveryMaterialsFee;
  788. formData.data.orderSkuList[index].lssueFee = res.lssueFee;
  789. formData.data.orderSkuList[index].packingLabor = res.packingLabor;
  790. formData.data.orderSkuList[index].unitPrice = res.unitPrice;
  791. formData.data.orderSkuList[index].subtotal = Number(
  792. Math.round(
  793. (res.customProcessingFee + res.deliveryMaterialsFee + res.lssueFee + res.packingLabor + res.unitPrice) *
  794. formData.data.orderSkuList[index].quantity *
  795. 100
  796. ) / 100
  797. );
  798. changeBOMQuantity(index);
  799. });
  800. }
  801. };
  802. const changeBOMQuantity = (index) => {
  803. if (formData.data.orderSkuList[index].orderSkuBomList && formData.data.orderSkuList[index].orderSkuBomList.length > 0) {
  804. if (formData.data.orderSkuList[index].quantity) {
  805. formData.data.orderSkuList[index].orderSkuBomList = formData.data.orderSkuList[index].orderSkuBomList.map((item) => {
  806. let allQuantity = 0;
  807. let allUnitPrice = 0;
  808. if (item.quantity) {
  809. allQuantity = Number(Math.round(Number(item.quantity) * Number(formData.data.orderSkuList[index].quantity)));
  810. }
  811. if (item.unitPrice) {
  812. allUnitPrice = Number(Math.round(Number(item.unitPrice) * Number(allQuantity) * 100) / 100);
  813. }
  814. return {
  815. ...item,
  816. allQuantity: allQuantity,
  817. allUnitPrice: allUnitPrice,
  818. };
  819. });
  820. } else {
  821. formData.data.orderSkuList[index].orderSkuBomList = formData.data.orderSkuList[index].orderSkuBomList.map((item) => {
  822. return {
  823. ...item,
  824. allQuantity: 0,
  825. allUnitPrice: 0,
  826. };
  827. });
  828. }
  829. }
  830. calculatedAmount();
  831. };
  832. const calculatedAmount = () => {
  833. let productTotalAmount = 0;
  834. let customProcessingFee = 0;
  835. let lssueFee = 0;
  836. let deliveryMaterialsFee = 0;
  837. let packingLabor = 0;
  838. let packagingMaterialCost = 0;
  839. let totalAmount = 0;
  840. if (formData.data.orderSkuList && formData.data.orderSkuList.length > 0) {
  841. for (let i = 0; i < formData.data.orderSkuList.length; i++) {
  842. if (formData.data.orderSkuList[i].quantity) {
  843. if (formData.data.orderSkuList[i].customProcessingFee) {
  844. customProcessingFee = Number(
  845. Math.round((customProcessingFee + formData.data.orderSkuList[i].customProcessingFee * formData.data.orderSkuList[i].quantity) * 100) / 100
  846. );
  847. }
  848. if (formData.data.orderSkuList[i].lssueFee) {
  849. lssueFee = Number(Math.round((lssueFee + formData.data.orderSkuList[i].lssueFee * formData.data.orderSkuList[i].quantity) * 100) / 100);
  850. }
  851. if (formData.data.orderSkuList[i].deliveryMaterialsFee) {
  852. deliveryMaterialsFee = Number(
  853. Math.round((deliveryMaterialsFee + formData.data.orderSkuList[i].deliveryMaterialsFee * formData.data.orderSkuList[i].quantity) * 100) / 100
  854. );
  855. }
  856. if (formData.data.orderSkuList[i].packingLabor) {
  857. packingLabor = Number(Math.round((packingLabor + formData.data.orderSkuList[i].packingLabor * formData.data.orderSkuList[i].quantity) * 100) / 100);
  858. }
  859. if (formData.data.orderSkuList[i].unitPrice) {
  860. productTotalAmount = Number(
  861. Math.round((productTotalAmount + formData.data.orderSkuList[i].unitPrice * formData.data.orderSkuList[i].quantity) * 100) / 100
  862. );
  863. }
  864. let money = 0;
  865. if (formData.data.orderSkuList[i].orderSkuBomList && formData.data.orderSkuList[i].orderSkuBomList.length > 0) {
  866. for (let j = 0; j < formData.data.orderSkuList[i].orderSkuBomList.length; j++) {
  867. if (formData.data.orderSkuList[i].orderSkuBomList[j].quantity && formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice) {
  868. packagingMaterialCost = Number(
  869. Math.round(
  870. (packagingMaterialCost +
  871. formData.data.orderSkuList[i].orderSkuBomList[j].quantity *
  872. formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice *
  873. formData.data.orderSkuList[i].quantity) *
  874. 100
  875. ) / 100
  876. );
  877. money = Number(
  878. Math.round(
  879. (money + formData.data.orderSkuList[i].orderSkuBomList[j].quantity * formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice) * 100
  880. ) / 100
  881. );
  882. }
  883. }
  884. }
  885. formData.data.orderSkuList[i].packagingMaterialCost = money;
  886. }
  887. }
  888. }
  889. formData.data.productTotalAmount = productTotalAmount;
  890. formData.data.customProcessingFee = customProcessingFee;
  891. formData.data.lssueFee = lssueFee;
  892. formData.data.deliveryMaterialsFee = deliveryMaterialsFee;
  893. formData.data.packingLabor = packingLabor;
  894. formData.data.packagingMaterialCost = packagingMaterialCost;
  895. totalAmount = Number(
  896. Math.round((productTotalAmount + customProcessingFee + lssueFee + deliveryMaterialsFee + packingLabor + packagingMaterialCost) * 100) / 100
  897. );
  898. formData.data.totalAmount = totalAmount;
  899. };
  900. </script>
  901. <style lang="scss" scoped>
  902. ::v-deep(.el-input-number .el-input__inner) {
  903. text-align: left;
  904. }
  905. :deep(.el-dialog) {
  906. margin-top: 10px !important;
  907. margin-bottom: 10px !important;
  908. }
  909. :deep(.ql-editor) {
  910. height: auto;
  911. }
  912. :deep(.el-collapse-item__header) {
  913. justify-content: center;
  914. }
  915. :deep(.el-collapse-item__arrow) {
  916. margin: 0;
  917. }
  918. .avatar-uploader .avatar {
  919. width: 148px;
  920. height: 148px;
  921. display: block;
  922. background-color: black;
  923. }
  924. .avatar-uploader .el-upload {
  925. border: 1px dashed var(--el-border-color);
  926. border-radius: 6px;
  927. cursor: pointer;
  928. position: relative;
  929. overflow: hidden;
  930. transition: var(--el-transition-duration-fast);
  931. }
  932. .avatar-uploader .el-upload:hover {
  933. border-color: var(--el-color-primary);
  934. }
  935. .el-icon.avatar-uploader-icon {
  936. font-size: 28px;
  937. color: #8c939d;
  938. width: 148px;
  939. height: 148px;
  940. text-align: center;
  941. border: 1px dashed var(--el-border-color);
  942. }
  943. :deep(.el-table__cell) {
  944. vertical-align: top;
  945. }
  946. </style>