add.vue 45 KB

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