collectCloth.vue 79 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684
  1. <template>
  2. <div class="app-container" style="height: calc(100vh - 84px)">
  3. <el-main style="height: calc(100vh - 180px - 84px)">
  4. <el-row :gutter="20">
  5. <el-col :span="6" :xs="24">
  6. <el-card class="box-card">
  7. <div slot="header" class="clearfix">
  8. <span>选择客户</span>
  9. </div>
  10. <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" @submit.native.prevent>
  11. <el-form-item prop="phoneNumber">
  12. <el-input v-model="queryParams.phoneNumber" placeholder="请输入手机号" clearable @keyup.enter.native="searchUser" />
  13. </el-form-item>
  14. <!-- <el-form-item label="姓名" prop="realName">-->
  15. <!-- <el-input-->
  16. <!-- v-model="queryParams.realName"-->
  17. <!-- placeholder="请输入姓名"-->
  18. <!-- clearable-->
  19. <!-- @keyup.enter.native="handleQuery"-->
  20. <!-- />-->
  21. <!-- </el-form-item>-->
  22. <el-form-item>
  23. <el-button type="primary" icon="el-icon-full-screen" @click="qrcodeSearchUser">扫码</el-button>
  24. <el-button type="primary" icon="el-icon-search" @click="searchUser">查询</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <el-descriptions title="用户信息" v-if="appUserInfo" :column="2">
  28. <el-descriptions-item label="用户名">{{ appUserInfo.realName }}</el-descriptions-item>
  29. <el-descriptions-item label="手机号">{{ appUserInfo.phoneNumber }}</el-descriptions-item>
  30. <el-descriptions-item label="等级">{{ appUserInfo.level }}</el-descriptions-item>
  31. <el-descriptions-item label="现金余额">
  32. {{ (appUserInfo.rechargeBalance * 100) / 100 }}
  33. </el-descriptions-item>
  34. <el-descriptions-item label="赠送余额">
  35. {{ (appUserInfo.giveBalance * 100) / 100 }}
  36. </el-descriptions-item>
  37. <el-descriptions-item label="福利金">
  38. {{ (appUserInfo.welfareBalance * 100) / 100 }}
  39. </el-descriptions-item>
  40. <el-descriptions-item label="地址" :span="2">{{ appUserInfo.defaultAddress ? appUserInfo.defaultAddress.address + ' ' + appUserInfo.defaultAddress.addressDetail : '' }}</el-descriptions-item>
  41. </el-descriptions>
  42. </el-card>
  43. </el-col>
  44. <el-col :span="18" :xs="24">
  45. <div style="width: 100%" class="verticle-view">
  46. <el-form :inline="true" label-width="68px">
  47. <el-form-item>
  48. <el-button type="primary" plain icon="el-icon-plus" @click="handleAdd">添加衣物</el-button>
  49. </el-form-item>
  50. </el-form>
  51. <el-table :data="orderClothItemDTOS" fit highlight-current-row border stripe ref="clothTable">
  52. <el-table-column label="序号" type="index" align="center" fixed="left" width="80"> </el-table-column>
  53. <el-table-column label="衣物名称" align="center" prop="name">
  54. <template slot-scope="scope">
  55. <span @click="updateClothItem(scope.$index, 0)">{{ calculateClothName(scope.$index) }}</span>
  56. </template>
  57. </el-table-column>
  58. <el-table-column label="颜色" align="center" width="120">
  59. <template slot-scope="scope">
  60. <span @click="updateClothItem(scope.$index, 2)">
  61. <template v-for="(color, index) in scope.row.orderClothColorDTOS">
  62. {{ index == 0 ? color.clothColorName : ',' + color.clothColorName }}
  63. </template>
  64. </span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="衣服品牌" align="center" prop="name" width="120">
  68. <template slot-scope="scope">
  69. <span @click="updateClothItem(scope.$index, 3)">{{ scope.row.clothBrandName }}</span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="瑕疵" align="center">
  73. <template slot-scope="scope">
  74. <span @click="updateClothItem(scope.$index, 4)">
  75. <template v-for="(color, index) in scope.row.orderClothFlawDTOS">
  76. {{ index == 0 ? color.clothFlawName : ',' + color.clothFlawName }}
  77. </template>
  78. </span>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="洗涤方式" align="center" width="80">
  82. <template slot-scope="scope">
  83. <span @click="changeClothWashMode(scope.$index)" style="color: #409eff">{{ scope.row.clothWashModeName }}</span>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="特殊处理(元)" align="center" prop="clothWashDayNum" width="120">
  87. <template slot-scope="scope">
  88. <span style="color: #ff4949" @click="changeClothSpecialPriceEvent(scope.$index)">{{ calculateClothSpecialPrice(scope.$index) }}</span>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="单价(元)" align="center" prop="defaultPrice" width="100">
  92. <template slot-scope="scope">
  93. <span style="color: #ff4949" v-if="scope.row.isChangePrice == 'Y'" @click="changeClothDefaultPriceEvent(scope.$index)">{{ scope.row.defaultPrice }}</span>
  94. <span v-else>{{ scope.row.defaultPrice }}</span>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="200">
  98. <template slot-scope="scope">
  99. <el-button type="text" @click="handleAddClothFlaw(scope.$index)">附件({{ scope.row.orderClothAdjunctDTOS.length }})</el-button>
  100. <!-- <el-button
  101. type="text"
  102. @click="handleAddClothPics(scope.$index)"
  103. >
  104. {{'拍照(' + scope.row.picNum + ')'}}
  105. </el-button> -->
  106. <el-button type="text" icon="el-icon-camera" @click="handphotograph(scope.$index)">{{ '拍照(' + scope.row.picNum + ')' }}</el-button>
  107. <el-button type="text" style="color: #ff4949" @click="orderClothItemDTOS.splice(scope.$index, 1)">删除</el-button>
  108. <el-button type="text" @click="handleRemarkClothItem(scope.$index)">备注</el-button>
  109. <el-button type="text" @click="handleCopyClothItem(scope.$index)">复制</el-button>
  110. </template>
  111. </el-table-column>
  112. </el-table>
  113. </div>
  114. </el-col>
  115. </el-row>
  116. </el-main>
  117. <el-row :gutter="10" class="box-shadow">
  118. <el-col :span="21">
  119. <el-form label-width="100px" style="height: 180px; padding-top: 20px" :inline="true" size="medium" :model="orderForm" ref="orderForm">
  120. <el-form-item label="总件数:" prop="totalClothNum">
  121. <span>{{ orderClothItemDTOS.length }}</span>
  122. </el-form-item>
  123. <el-form-item label="总金额:" prop="totalPrice">
  124. <span>{{ calculateTotalPrice() }}</span>
  125. </el-form-item>
  126. <el-form-item label="实收金额:" prop="totalPrice">
  127. <span style="color: #ff4949">{{ calculateTotalPrice() }}</span>
  128. </el-form-item>
  129. <el-form-item label="订单加急" prop="orderSpeed">
  130. <el-select v-model="orderForm.speed" placeholder="请选择" clearable>
  131. <template v-for="(item, index) in clothSpeeds">
  132. <el-option v-if="index > 1" :key="item.id" :label="item.name" :value="item.id"> </el-option>
  133. </template>
  134. </el-select>
  135. </el-form-item>
  136. <el-form-item label="是否关联预约" prop="isAppointment">
  137. <el-radio-group v-model="orderForm.isAppointment">
  138. <el-radio-button v-for="dict in dict.type.sys_yes_no" :key="dict.value" :label="dict.value">{{ dict.label }}</el-radio-button>
  139. </el-radio-group>
  140. </el-form-item>
  141. <el-form-item label="预约单号" prop="orderNo" v-if="orderForm.isAppointment == 'Y'">
  142. <el-input v-model="orderForm.orderNo" placeholder="请输入预约单号" clearable required />
  143. </el-form-item>
  144. <br />
  145. <el-form-item label="会员余额:" prop="userAmount">
  146. <span v-if="appUserInfo">{{ Math.round((appUserInfo.rechargeBalance + appUserInfo.giveBalance) * 100) / 100 }}</span>
  147. <span v-else>0</span>
  148. </el-form-item>
  149. <!-- <el-form-item label="取衣时间" prop="takeClothTime">
  150. <el-date-picker
  151. v-model="orderForm.takeClothTime"
  152. format="yyyy-MM-dd HH:mm"
  153. value-format="yyyy-MM-dd HH:mm"
  154. :style="{width: '100%'}"
  155. placeholder="请选择取衣时间"
  156. clearable
  157. ></el-date-picker>
  158. </el-form-item> -->
  159. <el-form-item v-if="orderForm.isAppointment == 'Y'" label="取衣方式" prop="sendClothWay">
  160. <el-select v-model="orderForm.sendClothWay" placeholder="请选择" clearable>
  161. <el-option
  162. v-for="dict in dict.type.cloth_send_type"
  163. :key="dict.value"
  164. :label="dict.label"
  165. :value="dict.value"
  166. />
  167. </el-select>
  168. </el-form-item>
  169. <el-form-item label="备注" prop="remark">
  170. <el-input v-model="orderForm.remark" placeholder="请输入订单备注" clearable />
  171. </el-form-item>
  172. </el-form>
  173. </el-col>
  174. <el-col :span="3">
  175. <el-button type="danger" style="height: 100%; width: 80%; height: 120px; margin-top: 30px" icon="el-icon-shopping-cart-2" size="medium" @click="handleConfirmPay">收银</el-button>
  176. </el-col>
  177. <!-- <el-col :span="3">-->
  178. <!-- <el-button type="primary" style="height: 100%; width: 80%; height: 120px; margin-top: 30px" icon="el-icon-sell">取衣付款</el-button>-->
  179. <!-- </el-col>-->
  180. </el-row>
  181. <!-- 添加或修改洗衣订单衣服明细对话框 -->
  182. <el-dialog :title="title" :visible.sync="open" size="50%" append-to-body>
  183. <el-row :gutter="15">
  184. <el-col :span="24">
  185. <el-steps :active="addClothActiveTab" finish-status="success" simple>
  186. <el-step title="衣服分类"></el-step>
  187. <el-step title="选择衣服"></el-step>
  188. <el-step title="衣服颜色"></el-step>
  189. <el-step title="衣服品牌"></el-step>
  190. <el-step title="衣服瑕疵"></el-step>
  191. <el-step title="衣服附件"></el-step>
  192. </el-steps>
  193. </el-col>
  194. <el-col>
  195. <div style="height: 20px"></div>
  196. </el-col>
  197. <el-col :span="24" v-if="addClothActiveTab == 0">
  198. <div style="margin-left: 55px">
  199. <el-input v-model="defaultList.type" placeholder="请输入要搜索的衣服分类" style="width: 300px;" clearable>
  200. <el-button slot="append" icon="el-icon-search" @click="searchCloth('type', 'clothTypes')"></el-button>
  201. </el-input>
  202. </div>
  203. <div style="margin-left: 40px">
  204. <el-tag :key="item.id" type="info" v-for="item in clothTypes" style="margin-top: 15px; margin-left: 15px" size="medium" @click="onClothTypeSelect(item.id)">
  205. {{ item.name }}
  206. </el-tag>
  207. </div>
  208. </el-col>
  209. <el-col :span="24" v-if="addClothActiveTab == 1">
  210. <div style="margin-left: 55px; margin-bottom: 10px">
  211. <el-input v-model="defaultList.item" placeholder="请输入要搜索的衣服类型" style="width: 300px;" clearable>
  212. <el-button slot="append" icon="el-icon-search" @click="searchCloth('item', 'clothItems')"></el-button>
  213. </el-input>
  214. </div>
  215. <div style="margin-left: 40px">
  216. <div class="horizontal-view" style="margin-left: 15px">
  217. <span style="font-size: 14px; line-height: 19px">衣服类型:</span>
  218. <el-checkbox-group style="margin-left: 20px" v-model="form.clothTypeKeys">
  219. <el-checkbox v-for="dict in dict.type.cloth_type" :key="dict.value" :label="dict.value">{{ dict.label }}</el-checkbox>
  220. </el-checkbox-group>
  221. </div>
  222. <el-tag :key="item.id" type="info" v-for="(item, index) in clothItems" style="margin-top: 15px; margin-left: 15px" size="medium" @click="onClothItemSelect(index)">
  223. {{ item.name }}
  224. </el-tag>
  225. </div>
  226. </el-col>
  227. <el-col :span="24" v-if="addClothActiveTab == 2">
  228. <div style="margin-left: 55px; margin-bottom: 10px">
  229. <el-input v-model="defaultList.color" placeholder="请输入要搜索的衣服颜色" style="width: 300px;" clearable>
  230. <el-button slot="append" icon="el-icon-search" @click="searchCloth('color', 'clothColors')"></el-button>
  231. </el-input>
  232. </div>
  233. <div style="margin-left: 40px; display: flex; flex-wrap: wrap">
  234. <template v-for="(item, index) in clothColors">
  235. <div class="verticle-view" :style="'text-align: center;margin-top: 15px;margin-left: 15px;border-radius: 5px;border: 1px solid ' + (item.isSelect == true ? '#1890ff' : '#FFFFFF')" @click="onClothColorSelect(index)">
  236. <template v-if="item.colorType == 0">
  237. <div :style="'width: 50px;height: 50px;border:1px solid #ededed;border-radius: 5px;background-color:' + item.code"></div>
  238. </template>
  239. <template v-if="item.colorType == 1">
  240. <img :src="item.imgUrl" style="width: 50px; height: 50px; border-radius: 5px" />
  241. </template>
  242. <span style="height: 40px; line-height: 40px">{{ item.name }}</span>
  243. </div>
  244. </template>
  245. </div>
  246. </el-col>
  247. <el-col :span="24" v-if="addClothActiveTab == 3">
  248. <div style="margin-left: 55px;">
  249. <el-input v-model="defaultList.brand" placeholder="请输入要搜索的衣服品牌" style="width: 300px;" clearable>
  250. <el-button slot="append" icon="el-icon-search" @click="searchCloth('brand', 'clothBrands')"></el-button>
  251. </el-input>
  252. </div>
  253. <div style="margin-left: 40px">
  254. <el-tag :key="item.id" type="info" v-for="item in clothBrands" style="margin-top: 15px; margin-left: 15px" size="medium" @click="onClothBrandSelect(item.id)">
  255. {{ item.name }}
  256. </el-tag>
  257. </div>
  258. </el-col>
  259. <el-col :span="24" v-if="addClothActiveTab == 4">
  260. <el-tabs type="border-card" @tab-click="changeClothTab">
  261. <el-tab-pane label="全部">
  262. <div style="margin-left: 15px;">
  263. <el-input v-model="defaultList.flaw" placeholder="请输入要搜索的衣服瑕疵" style="width: 300px;" clearable>
  264. <el-button slot="append" icon="el-icon-search" @click="searchCloth('flaw', 'clothFlaws')"></el-button>
  265. </el-input>
  266. </div>
  267. <el-tag :key="item.id" :type="item.isSelect ? 'success' : 'info'" v-for="(item, index) in clothFlaws" style="margin-top: 15px; margin-left: 15px" size="medium" @click="onClothFlawSelect(index)">
  268. {{ item.name }}
  269. </el-tag>
  270. </el-tab-pane>
  271. <el-tab-pane :label="clothFlawType.name" v-for="clothFlawType in clothFlawTypes">
  272. <div style="margin-left: 15px;">
  273. <el-input v-model="defaultList.flaw" placeholder="请输入要搜索的衣服瑕疵" style="width: 300px;" clearable>
  274. <el-button slot="append" icon="el-icon-search" @click="searchCloth('flaw', 'clothFlaws')"></el-button>
  275. </el-input>
  276. </div>
  277. <template v-for="(item, index) in clothFlaws">
  278. <el-tag :key="item.id" :type="item.isSelect ? 'success' : 'info'" v-if="item.flawTypeId == clothFlawType.id" style="margin-top: 15px; margin-left: 15px" size="medium" @click="onClothFlawSelect(index)">
  279. {{ item.name }}
  280. </el-tag>
  281. </template>
  282. </el-tab-pane>
  283. </el-tabs>
  284. </el-col>
  285. <el-col :span="24" v-if="addClothActiveTab == 5">
  286. <el-row :gutter="20">
  287. <el-col :span="8">
  288. <div>选择附件</div>
  289. <div style="margin-left: 15px; margin-top: 10px;">
  290. <el-input v-model="defaultList.adjunct" placeholder="请输入要搜索的衣服附件" style="width: 300px;" clearable>
  291. <el-button slot="append" icon="el-icon-search" @click="searchCloth('adjunct', 'clothAdjuncts')"></el-button>
  292. </el-input>
  293. </div>
  294. <el-tag :key="item.id" type="info" v-for="item in clothAdjuncts" style="margin-top: 15px; margin-left: 15px" @click="onClothAdjunctSelect(item)">
  295. {{ item.name }}
  296. </el-tag>
  297. </el-col>
  298. <el-col :span="16">
  299. <el-table :data="addClothAdjuncts" style="width: 100%">
  300. <el-table-column label="附件" align="center" prop="adjunctName" />
  301. <el-table-column label="数量" align="center" prop="num">
  302. <template slot-scope="scope">
  303. <el-input-number v-model="scope.row.num" size="small" :precision="0" :min="1" :max="999"></el-input-number>
  304. </template>
  305. </el-table-column>
  306. <el-table-column label="操作" align="center">
  307. <template slot-scope="scope">
  308. <el-button type="text" icon="el-icon-delete" @click="removeClothAdjunct(scope.$index)">删除</el-button>
  309. </template>
  310. </el-table-column>
  311. </el-table>
  312. </el-col>
  313. </el-row>
  314. </el-col>
  315. </el-row>
  316. <div slot="footer" class="dialog-footer" v-if="addClothActiveTab == 2 || addClothActiveTab == 4 || addClothActiveTab == 5">
  317. <el-button type="primary" @click="addClothItemConfirm" style="margin-left: 5%">确定</el-button>
  318. </div>
  319. </el-dialog>
  320. <el-dialog title="衣服附件" :visible.sync="addClothAdjunctOpen" width="50%">
  321. <el-row :gutter="20">
  322. <el-col :span="8">
  323. <div>选择附件</div>
  324. <div style="margin-left: 55px">
  325. <el-input v-model="defaultList.adjunct" placeholder="请输入要搜索的衣服附件" style="width: 300px;" clearable>
  326. <el-button slot="append" icon="el-icon-search" @click="searchCloth('adjunct', 'clothAdjuncts')"></el-button>
  327. </el-input>
  328. </div>
  329. <el-tag :key="item.id" type="info" v-for="item in clothAdjuncts" style="margin-top: 15px; margin-left: 15px" @click="onClothAdjunctSelect(item)">
  330. {{ item.name }}
  331. </el-tag>
  332. </el-col>
  333. <el-col :span="16">
  334. <el-table :data="addClothAdjuncts" style="width: 100%">
  335. <el-table-column label="附件" align="center" prop="adjunctName" />
  336. <el-table-column label="数量" align="center" prop="num">
  337. <template slot-scope="scope">
  338. <el-input-number v-model="scope.row.num" size="small" :precision="0" :min="1" :max="999"></el-input-number>
  339. </template>
  340. </el-table-column>
  341. <el-table-column label="操作" align="center">
  342. <template slot-scope="scope">
  343. <el-button type="text" icon="el-icon-delete" @click="removeClothAdjunct(scope.$index)">删除</el-button>
  344. </template>
  345. </el-table-column>
  346. </el-table>
  347. </el-col>
  348. </el-row>
  349. <span slot="footer" class="dialog-footer">
  350. <el-button @click="addClothAdjunctOpen = false">取 消</el-button>
  351. <el-button type="primary" @click="addClothAdjunctSubmit">确 定</el-button>
  352. </span>
  353. </el-dialog>
  354. <el-dialog title="衣服照片" :visible.sync="addClothPicOpen" width="50%">
  355. <form ref="picForm">
  356. <image-upload :limit="9" v-model="addClothPics"></image-upload>
  357. </form>
  358. <span slot="footer" class="dialog-footer">
  359. <el-button @click="addClothPicOpen = false">取 消</el-button>
  360. <el-button type="primary" @click="addClothPicSubmit">确 定</el-button>
  361. </span>
  362. </el-dialog>
  363. <el-dialog title="洗衣方式" :visible.sync="addClothWashModeOpen" width="30%">
  364. <div style="margin-bottom: 50px">
  365. <el-tag :key="item.id" type="info" v-for="(item, index) in clothWashModes" style="margin-top: 15px; margin-left: 15px" size="medium" @click="onClothWashModeSelect(index)">
  366. {{ item.washModeName + '(¥' + item.price + ')' }}
  367. </el-tag>
  368. </div>
  369. </el-dialog>
  370. <!-- 设置备注 -->
  371. <el-dialog title="备注" :visible.sync="addClothRemarkOpen" width="30%">
  372. <form ref="remarkForm">
  373. <el-input type="textarea" :rows="5" placeholder="请输入备注" v-model="clothRemark"> </el-input>
  374. </form>
  375. <span slot="footer" class="dialog-footer">
  376. <el-button @click="addClothPicOpen = false">取 消</el-button>
  377. <el-button type="primary" @click="addClothRemarkSubmit">确 定</el-button>
  378. </span>
  379. </el-dialog>
  380. <!-- 设置默认价格 -->
  381. <el-dialog title="设置价格" :visible.sync="setClothDefaultPriceOpen" width="30%" :before-close="handleClose">
  382. <form ref="remarkForm">
  383. <el-input-number placeholder="请输入价格" v-model="defaultPrice"> </el-input-number>
  384. </form>
  385. <span slot="footer" class="dialog-footer">
  386. <el-button @click="setClothDefaultPriceOpen = false">取 消</el-button>
  387. <el-button type="primary" @click="setClothDefaultPriceSubmit">确 定</el-button>
  388. </span>
  389. </el-dialog>
  390. <!-- 特殊衣物 -->
  391. <el-dialog title="特殊衣物" :visible.sync="setClothSpecialPriceOpen" width="55%" :before-close="handleClose">
  392. <el-form ref="remarkForm">
  393. <el-row :gutter="10">
  394. <el-col :span="12">
  395. <el-card class="box-card">
  396. <div slot="header" class="clearfix">
  397. <span>工艺加价</span>
  398. </div>
  399. <template v-for="(item, index) in clothSpecialForm.clothCrafts">
  400. <el-form-item>
  401. <el-checkbox v-model="item.isSelect" @change="changeClothCraftSelect()" style="width: 100px">{{ item.clothCraftName }}</el-checkbox>
  402. <el-input-number v-model="item.price" :min="0" :max="9999" :precision="2" @change="changeClothCraftSelect"></el-input-number>
  403. </el-form-item>
  404. </template>
  405. </el-card>
  406. </el-col>
  407. <el-col :span="12">
  408. <el-card class="box-card">
  409. <div slot="header" class="clearfix">
  410. <span>保值加急</span>
  411. </div>
  412. <el-form-item>
  413. <el-checkbox v-model="clothSpecialForm.isHedging" @change="changeClothHedgingSelect()" style="width: 100px">保值</el-checkbox>
  414. <el-input-number v-model="clothSpecialForm.hedgingPrice" :min="0" :max="9999" :precision="0" @change="changeClothHedgingSelect()"></el-input-number>
  415. <span style="margin-left: 5px">元 {{ clothSpecialForm.hedgingPrice && clothSpecialForm.isHedging ? '(¥' + clothSpecialForm.hedgingPrice * 0.01 + ')' : '' }}</span>
  416. </el-form-item>
  417. <template v-for="(item, index) in clothSpecialForm.clothSpeeds">
  418. <el-form-item v-if="item.isDefault != 'Y' && selectClothItemIndex > -1">
  419. <el-checkbox v-model="item.isSelect" @change="changeClothSpeedSelect(index)" style="width: 100px" :disabled="clothSpecialForm.isHedging && index == 1">
  420. <span v-if="item.isSelect">{{ item.name + '(¥' + orderClothItemDTOS[selectClothItemIndex].defaultPrice * (item.multiple - 1) + ')' }}</span>
  421. <span v-else>{{ item.name }}</span>
  422. </el-checkbox>
  423. <span>{{ item.price }}</span>
  424. </el-form-item>
  425. </template>
  426. </el-card>
  427. </el-col>
  428. </el-row>
  429. </el-form>
  430. <span slot="footer" class="dialog-footer">
  431. <el-button @click="setClothSpecialPriceOpen = false">取 消</el-button>
  432. <el-button type="primary" @click="addClothSpecialSubmit">确 定</el-button>
  433. </span>
  434. </el-dialog>
  435. <el-dialog title="收银" :visible.sync="confirmPayOpen" size="80%" :before-close="handleClose" destroy-on-close>
  436. <CashCloth ref="cashCloth" :orderForm="orderForm" :orderClothItemDTOS="orderClothItemDTOS" :appUserInfo="appUserInfo" :clothSpeeds="clothSpeeds" :deductCouponVOS="deductCouponVOS" :discountCouponVOS="discountCouponVOS" @onPaySuccess="onPaySuccess" @initOrderList="initOrderList" />
  437. </el-dialog>
  438. <!-- 拍照上传 -->
  439. <el-dialog title="拍照上传" :visible.sync="photographType" :before-close="hidephotograph" width="55%">
  440. <div class="photo_content">
  441. <div class="video_content">
  442. <div class="loading" v-if="videoType">
  443. <el-button type="text" :loading="true" disabled>加载中请稍后</el-button>
  444. </div>
  445. <video class="videoElement" ref="videoElement" autoplay></video>
  446. </div>
  447. <div class="view">
  448. <div class="btn_box">
  449. <el-button class="btn_photo" :loading="photoType" :disabled="photoType" icon="el-icon-camera" type="primary" plain @click="takePhoto" v-if="!videoType">拍照上传</el-button>
  450. <el-upload v-if="photographimgList.length < 9" class="btn_upload" :action="uploadAction" :before-upload="handleBeforeUpload" :on-success="handleUploadSuccess" :on-error="handleUploadError" accept="image/*" :show-file-list="false" ref="fileUpload">
  451. <el-button icon="el-icon-folder" plain type="primary">上传本地文件</el-button>
  452. </el-upload>
  453. </div>
  454. <div class="image_list" v-if="photographimgList.length">
  455. <div class="image_item" v-for="(item, index) in photographimgList" :key="index">
  456. <el-image style="width: 120px; height: 120px" :src="item.src ? item.src : item.url" :preview-src-list="previewimgList"> </el-image>
  457. <div class="image_bottom">
  458. <el-button type="danger" icon="el-icon-delete" @click="btn_remove(item, index)"></el-button>
  459. <el-button v-if="item.type" type="success" icon="el-icon-check"></el-button>
  460. </div>
  461. </div>
  462. </div>
  463. <el-empty :image-size="200" v-else></el-empty>
  464. </div>
  465. </div>
  466. <span slot="footer" class="dialog-footer">
  467. <el-button @click="hidephotograph">关 闭</el-button>
  468. <el-button type="primary" @click="btn_submit">保 存</el-button>
  469. </span>
  470. </el-dialog>
  471. <pay-status-popup ref="payStatusPopup" @paySuccess="handelPaySuccess"></pay-status-popup>
  472. </div>
  473. </template>
  474. <style>
  475. /*.box-shadow .el-button--medium{*/
  476. /* font-size: 18px;*/
  477. /*}*/
  478. </style>
  479. <script>
  480. import CashCloth from './component/cashCloth'
  481. import payStatusPopup from '@/components/payStatusPopup'
  482. import { listClothItem, getClothItem, delClothItem, addClothItem, updateClothItem, updateClothItemStatus } from '@/api/order/clothItem'
  483. import { uploadBase64OSS, uploadOSS, saveOrderClothPics } from '@/api/upload'
  484. import { getOrderStatusByOrderNo } from '../../../api/order/cloth'
  485. import { allList } from '@/api/core/clothType'
  486. import { allClothItem } from '../../../api/core/clothItem'
  487. import { allClothColor } from '../../../api/core/color'
  488. import { allClothFlaw } from '@/api/core/flaw'
  489. import { allClothFlawType } from '@/api/core/flawType'
  490. import { allClothAdjunct } from '../../../api/cloth/adjunct'
  491. import { findUserByPhoneNumber } from '@/api/app/user'
  492. import { listWashModePriceByClothId } from '../../../api/cloth/price'
  493. import { allClothSpeed } from '../../../api/cloth/speed'
  494. import { allClothCraft } from '../../../api/cloth/craft'
  495. import { collectCloth, getInfoByOrderNo, clothOrderPay } from '../../../api/order/cloth'
  496. import { allBrand } from '../../../api/cloth/brand'
  497. import { getCouponItemlistByAppUserId, getDiscountByStoreId } from '../../../api/coupon/item'
  498. import { add, multi, minute, sub } from '../../../utils/math'
  499. export default {
  500. name: 'CollectCloth',
  501. components: { CashCloth, payStatusPopup },
  502. dicts: ['sys_yes_no', 'cloth_type', 'cloth_send_type'],
  503. data() {
  504. return {
  505. uploadAction: `${process.env.VUE_APP_BASE_API}` + '/common/uploadOSS',
  506. appUserInfo: null,
  507. checkOrderStatusNum: 0,
  508. checkOrderIntervalId: null,
  509. addClothActiveTab: 0,
  510. defaultList: {
  511. type: '',
  512. clothTypes: [],
  513. item: '',
  514. clothItems: [],
  515. color: '',
  516. clothColors: [],
  517. brand: '',
  518. clothBrands: [],
  519. flaw: '',
  520. clothFlaws: [],
  521. adjunct: '',
  522. clothAdjuncts: []
  523. },
  524. clothBrands: [],
  525. clothTypes: [],
  526. clothItems: [],
  527. clothColors: [],
  528. clothFlawTypes: [],
  529. clothFlaws: [],
  530. clothAdjuncts: [],
  531. clothWashModes: [],
  532. clothCrafts: [],
  533. clothSpeeds: [],
  534. orderForm: {
  535. isSpecial: 'N',
  536. isAppointment: 'N',
  537. authCode: '',
  538. payType: '3'
  539. },
  540. // 总条数
  541. total: 0,
  542. // 洗衣订单衣服明细表格数据
  543. orderClothItemDTOS: [],
  544. selectClothItemIndex: -1,
  545. selectCoupons: [],
  546. // 弹出层标题
  547. title: '',
  548. // 是否显示弹出层
  549. open: false,
  550. isUpdateClothItem: false,
  551. //衣服特殊价格设置
  552. setClothSpecialPriceOpen: false,
  553. clothSpecialForm: {},
  554. //衣服附件相关
  555. addClothAdjunctOpen: false,
  556. addClothAdjuncts: [],
  557. //衣服照片相关
  558. addClothPicOpen: false,
  559. addClothPics: null,
  560. //衣服洗衣方式
  561. addClothWashModeOpen: false,
  562. //衣服备注
  563. addClothRemarkOpen: false,
  564. clothRemark: '',
  565. setClothDefaultPriceOpen: false,
  566. defaultPrice: 0,
  567. confirmPayOpen: false,
  568. confirmCouponTabIndex: '0',
  569. confirmDeductTabIndex: '0',
  570. setCouponOpen: false, //是否选择优惠券
  571. discountCouponVOS: [], //可选择的折扣券
  572. deductCouponVOS: [], //可选择的抵扣券
  573. changeDiscountCouponIndex: -1,
  574. changeDiscountCouponOpen: false,
  575. changeDiscountCouponTitle: '',
  576. changeDiscountCouponSelectCloths: [],
  577. changeDiscountCouponCanSelectCloths: [],
  578. // 查询参数
  579. queryParams: {},
  580. // 表单参数
  581. form: {},
  582. // 表单校验
  583. rules: {},
  584. photographType: false,
  585. photographimgList: [],
  586. previewimgList: [],
  587. uploadList: [],
  588. photoLoading: true,
  589. clothId: null,
  590. stream: null,
  591. fileType: ['png', 'jpg', 'jpeg'],
  592. videoType: true,
  593. photoType: false,
  594. collectClothDetail: null
  595. }
  596. },
  597. mounted() {
  598. if (process.env.ENV != 'production') {
  599. window.vue = this
  600. }
  601. },
  602. created() {
  603. allClothCraft().then((res) => {
  604. this.clothCrafts = res.data
  605. this.clothCrafts.forEach((item) => {
  606. item.defaultPrice = 20
  607. })
  608. })
  609. allClothSpeed().then((speedRes) => {
  610. this.clothSpeeds = speedRes.data
  611. })
  612. },
  613. methods: {
  614. // 添加衣物过滤数据
  615. searchCloth(k1, k2) {
  616. if (!this.defaultList[k1]) {
  617. this[k2] = this.defaultList[k2]
  618. } else {
  619. this[k2] = this.defaultList[k2].filter((item) => {
  620. return item.name.indexOf(this.defaultList[k1]) > -1
  621. })
  622. }
  623. },
  624. // 切换衣服瑕疵分页
  625. changeClothTab() {
  626. this.defaultList.flaw = ''
  627. this.clothFlaws = this.defaultList.clothFlaws
  628. },
  629. // 上传前校检格式和大小
  630. handleBeforeUpload(file) {
  631. // 校检文件类型
  632. if (this.fileType) {
  633. const fileName = file.name.split('.')
  634. const fileExt = fileName[fileName.length - 1]
  635. const isTypeOk = this.fileType.indexOf(fileExt) >= 0
  636. if (!isTypeOk) {
  637. this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join('/')}格式文件!`)
  638. return false
  639. }
  640. }
  641. // 校检文件大小
  642. const isLt = file.size / 1024 / 1024 < 3
  643. if (!isLt) {
  644. this.$message.error(`上传文件大小不能超过 3MB!`)
  645. return false
  646. }
  647. this.$modal.loading('正在上传文件,请稍候...')
  648. return true
  649. },
  650. handleUploadSuccess(res, file) {
  651. if (res.code === 200) {
  652. this.previewimgList.push(res.data.src)
  653. this.uploadList.push({ name: res.data.fileName, url: res.data.src })
  654. this.uploadedSuccessfully()
  655. } else {
  656. this.$modal.closeLoading()
  657. this.$modal.msgError(res.msg)
  658. this.$refs.fileUpload.handleRemove(file)
  659. this.uploadedSuccessfully()
  660. }
  661. },
  662. handleUploadError() {
  663. this.$modal.msgError('上传文件失败,请重试')
  664. this.$modal.closeLoading()
  665. },
  666. // 上传结束处理
  667. uploadedSuccessfully() {
  668. if (this.uploadList.length) {
  669. // this.fileList = this.fileList.concat(this.uploadList);
  670. this.uploadList.forEach((item) => {
  671. this.photographimgList.push({
  672. src: item.url,
  673. fileName: item.fileName,
  674. type: true
  675. })
  676. })
  677. this.uploadList = []
  678. this.$modal.closeLoading()
  679. this.getuploadState()
  680. }
  681. },
  682. //根据上传文件状态判断显示
  683. getuploadState() {
  684. // 初始状态值
  685. let state = true
  686. // 判断数组中的所有元素是否都为true
  687. if (this.photographimgList.every((item) => item.type === true)) {
  688. state = false
  689. } else {
  690. state = true
  691. }
  692. return state
  693. },
  694. // 取消按钮
  695. cancel() {
  696. this.confirmPayOpen = false
  697. this.reset()
  698. },
  699. // 表单重置
  700. reset() {
  701. this.form = {
  702. orderClothCraftDTOS: [], //衣服工艺
  703. orderClothAdjunctDTOS: [],
  704. orderClothTypeDTOS: [],
  705. clothTypeKeys: [],
  706. specialPrice: 0,
  707. clothSpeedMultiple: 1,
  708. picNum: 0,
  709. isCustomPrice: 'N',
  710. remark: '',
  711. defaultPrice: 0
  712. }
  713. },
  714. /** 搜索按钮操作 */
  715. handleQuery() {
  716. this.queryParams.pageNum = 1
  717. },
  718. /** 重置按钮操作 */
  719. resetQuery() {
  720. this.resetForm('queryForm')
  721. this.handleQuery()
  722. },
  723. /** 新增按钮操作 */
  724. handleAdd() {
  725. allList().then((res) => {
  726. this.defaultList.type = ''
  727. this.defaultList.clothTypes = res.data
  728. this.clothTypes = res.data
  729. this.reset()
  730. this.selectClothItemIndex = -1
  731. this.addClothActiveTab = 0
  732. this.isUpdateClothItem = false
  733. this.open = true
  734. this.title = '添加衣物'
  735. })
  736. },
  737. /** 修改按钮操作 */
  738. handleUpdate(row) {
  739. this.reset()
  740. const id = row.id || this.ids
  741. getClothItem(id).then((response) => {
  742. this.form = response.data
  743. this.open = true
  744. this.title = '编辑衣物信息'
  745. })
  746. },
  747. initOrderList(e) {
  748. console.log('sssss', e)
  749. this.orderClothItemDTOS = e.concat()
  750. },
  751. onPaySuccess(orderInfo) {
  752. this.confirmPayOpen = false
  753. console.log('res', orderInfo)
  754. if (orderInfo.payTimeType == '0') {
  755. //第三方支付
  756. console.log('第三方支付')
  757. this.$refs.payStatusPopup.open(3, orderInfo, this.appUserInfo)
  758. // this.checkOrderStatusNum = 0
  759. // if (this.checkOrderIntervalId) {
  760. // clearInterval(this.checkOrderIntervalId)
  761. // }
  762. // this.checkOrderIntervalId = setInterval(() => {
  763. // this.intervalCheckOrderStatus(orderInfo.orderNo)
  764. // }, 4000)
  765. } else {
  766. this.$refs.payStatusPopup.open(1, orderInfo)
  767. this.orderClothItemDTOS = []
  768. this.queryParams = {}
  769. this.appUserInfo = null
  770. }
  771. },
  772. handelPaySuccess() {
  773. this.orderClothItemDTOS = []
  774. this.queryParams = {}
  775. this.appUserInfo = null
  776. },
  777. intervalCheckOrderStatus(orderno) {
  778. getOrderStatusByOrderNo({ orderNo: orderno }).then((response) => {
  779. if (this.checkOrderStatusNum > 15) {
  780. clearInterval(this.checkOrderIntervalId)
  781. return
  782. }
  783. if (response.data == '4') {
  784. return
  785. }
  786. if (response.data == '100') {
  787. //已取消
  788. this.$notify.error({
  789. title: '支付失败',
  790. message: '支付超时或客户已取消支付'
  791. })
  792. clearInterval(this.checkOrderIntervalId)
  793. return
  794. }
  795. this.$notify({
  796. title: '支付成功',
  797. message: '客户已成功支付订单',
  798. type: 'success'
  799. })
  800. this.pointerType = true
  801. clearInterval(this.checkOrderIntervalId)
  802. })
  803. },
  804. /** 关闭按钮 */
  805. close() {
  806. const obj = { path: '/workbench/collectCloth' }
  807. this.$tab.closeOpenPage(obj)
  808. },
  809. /** 删除按钮操作 */
  810. handleDelete(row) {
  811. const ids = row.id || this.ids
  812. this.$modal
  813. .confirm('是否确认删除洗衣订单衣服明细编号为"' + ids + '"的数据项?')
  814. .then(function () {
  815. return delClothItem(ids)
  816. })
  817. .then(() => {
  818. this.getList()
  819. this.$modal.msgSuccess('删除成功')
  820. })
  821. .catch(() => {})
  822. },
  823. checkClose(done) {
  824. this.$confirm('是否关闭表单,关闭后数据将丢失?')
  825. .then(function () {
  826. done()
  827. })
  828. .then(() => {})
  829. .catch(() => {})
  830. },
  831. onClothTypeSelect(id) {
  832. allClothItem({ clothTypeId: id }).then((res) => {
  833. this.defaultList.item = ''
  834. this.defaultList.clothItems = res.data
  835. this.clothItems = res.data
  836. this.addClothActiveTab = 1
  837. })
  838. },
  839. onClothItemSelect(index) {
  840. for (let i = 0; i < this.form.clothTypeKeys.length; i++) {
  841. var orderClothTypeDTO = { orderClothTypeCode: this.form.clothTypeKeys[i] }
  842. if (this.form.clothTypeKeys[i] == '1') {
  843. orderClothTypeDTO.clothTypeName = '加厚'
  844. orderClothTypeDTO.clothTypePrice = this.clothItems[index].plusPrice
  845. }
  846. if (this.form.clothTypeKeys[i] == '2') {
  847. orderClothTypeDTO.clothTypeName = '羊绒'
  848. orderClothTypeDTO.clothTypePrice = this.clothItems[index].silkPrice
  849. }
  850. if (this.form.clothTypeKeys[i] == '3') {
  851. orderClothTypeDTO.clothTypeName = '真丝'
  852. orderClothTypeDTO.clothTypePrice = this.clothItems[index].sheepPrice
  853. }
  854. if (this.form.clothTypeKeys[i] == '4') {
  855. orderClothTypeDTO.clothTypeName = '儿童'
  856. orderClothTypeDTO.clothTypePrice = this.clothItems[index].childPrice
  857. }
  858. this.form.orderClothTypeDTOS.push(orderClothTypeDTO)
  859. }
  860. this.form.clothWashModeId = this.clothItems[index].washId
  861. this.form.clothWashModeName = this.clothItems[index].washName
  862. if (this.isUpdateClothItem) {
  863. //修改已选择的衣服
  864. this.form.clothItemId = this.clothItems[index].id
  865. this.form = { ...this.form, ...this.clothItems[index] }
  866. this.form.isCustomPrice = 'N'
  867. this.orderClothItemDTOS[this.selectClothItemIndex] = this.form
  868. this.orderClothItemDTOS = this.orderClothItemDTOS.concat()
  869. for (let i = 0; i < this.form.clothTypeKeys.length; i++) {
  870. if (this.form.clothTypeKeys[i] == '1') {
  871. this.form.defaultPrice += this.clothItems[index].plusPrice
  872. }
  873. if (this.form.clothTypeKeys[i] == '2') {
  874. this.form.defaultPrice += this.clothItems[index].silkPrice
  875. }
  876. if (this.form.clothTypeKeys[i] == '3') {
  877. this.form.defaultPrice += this.clothItems[index].sheepPrice
  878. }
  879. if (this.form.clothTypeKeys[i] == '4') {
  880. this.form.defaultPrice += this.clothItems[index].childPrice
  881. }
  882. }
  883. this.open = false
  884. this.$forceUpdate()
  885. } else {
  886. allClothColor().then((res) => {
  887. this.defaultList.color = '';
  888. this.defaultList.clothColors = res.data
  889. this.clothColors = res.data
  890. this.form.clothItemId = this.clothItems[index].id
  891. this.form = { ...this.form, ...this.clothItems[index] }
  892. for (let i = 0; i < this.form.clothTypeKeys.length; i++) {
  893. if (this.form.clothTypeKeys[i] == '1') {
  894. this.form.defaultPrice += this.clothItems[index].plusPrice
  895. }
  896. if (this.form.clothTypeKeys[i] == '2') {
  897. this.form.defaultPrice += this.clothItems[index].silkPrice
  898. }
  899. if (this.form.clothTypeKeys[i] == '3') {
  900. this.form.defaultPrice += this.clothItems[index].sheepPrice
  901. }
  902. if (this.form.clothTypeKeys[i] == '4') {
  903. this.form.defaultPrice += this.clothItems[index].childPrice
  904. }
  905. }
  906. this.addClothActiveTab = 2
  907. })
  908. }
  909. },
  910. onClothColorSelect(index) {
  911. this.clothColors[index].isSelect = this.clothColors[index].isSelect ? false : true
  912. this.$forceUpdate()
  913. },
  914. onClothBrandSelect(id) {
  915. var brand = this.clothBrands.find((item) => item.id == id)
  916. this.form.clothBrandId = id
  917. this.form.clothBrandName = brand.name
  918. if (this.isUpdateClothItem) {
  919. this.orderClothItemDTOS[this.selectClothItemIndex].clothBrandId = id
  920. this.orderClothItemDTOS[this.selectClothItemIndex].clothBrandName = brand.name
  921. this.open = false
  922. } else {
  923. allClothFlawType().then((res) => {
  924. this.clothFlawTypes = res.data
  925. allClothFlaw().then((res1) => {
  926. this.defaultList.flaw = '';
  927. this.defaultList.clothFlaws = res1.data
  928. this.clothFlaws = res1.data
  929. this.addClothActiveTab = 4
  930. })
  931. })
  932. }
  933. },
  934. addClothItemConfirm() {
  935. if (this.addClothActiveTab == 2) {
  936. //选择颜色
  937. var clothColorDTOS = []
  938. this.clothColors.forEach((item) => {
  939. if (item.isSelect) {
  940. clothColorDTOS.push({ clothColorId: item.id, clothColorName: item.name })
  941. }
  942. })
  943. if (clothColorDTOS.length == 0) {
  944. this.$message.error('请先选择颜色')
  945. return
  946. }
  947. this.form.orderClothColorDTOS = clothColorDTOS
  948. if (this.isUpdateClothItem) {
  949. //修改已选择的衣服
  950. this.orderClothItemDTOS[this.selectClothItemIndex] = this.form
  951. this.orderClothItemDTOS = this.orderClothItemDTOS.concat()
  952. this.open = false
  953. this.$forceUpdate()
  954. } else {
  955. allBrand().then((res) => {
  956. res.data.push({
  957. id: '0',
  958. name: '无'
  959. })
  960. this.defaultList.brand = '';
  961. this.defaultList.clothBrands = res.data
  962. this.clothBrands = res.data
  963. this.addClothActiveTab = 3
  964. })
  965. }
  966. } else if (this.addClothActiveTab == 4) {
  967. //选择瑕疵
  968. var clothFlawDTOS = []
  969. this.clothFlaws.forEach((item) => {
  970. if (item.isSelect) {
  971. clothFlawDTOS.push({ clothFlawId: item.id, clothFlawName: item.name })
  972. }
  973. })
  974. if (clothFlawDTOS.length == 0) {
  975. this.$message.error('请先选择瑕疵')
  976. return
  977. }
  978. this.form.orderClothFlawDTOS = clothFlawDTOS
  979. if (this.isUpdateClothItem) {
  980. this.orderClothItemDTOS[this.selectClothItemIndex] = this.form
  981. this.orderClothItemDTOS = this.orderClothItemDTOS.concat()
  982. this.open = false
  983. this.$forceUpdate()
  984. } else {
  985. // this.orderClothItemDTOS.push(this.form)
  986. // console.log(this.orderClothItemDTOS)
  987. // this.open = false
  988. allClothAdjunct().then((res) => {
  989. this.defaultList.clothAdjuncts = res.data;
  990. this.defaultList.adjunct = ''
  991. this.clothAdjuncts = res.data
  992. this.addClothActiveTab = 5
  993. let index = this.orderClothItemDTOS.length
  994. this.selectClothItemIndex = index
  995. this.addClothAdjuncts = []
  996. this.$forceUpdate()
  997. })
  998. }
  999. } else if (this.addClothActiveTab == 5) {
  1000. this.orderClothItemDTOS.push(this.form)
  1001. this.addClothAdjunctSubmit()
  1002. this.open = false
  1003. }
  1004. },
  1005. onClothFlawSelect(index) {
  1006. this.clothFlaws[index].isSelect = this.clothFlaws[index].isSelect ? false : true
  1007. this.$forceUpdate()
  1008. },
  1009. //条码搜索用户
  1010. qrcodeSearchUser() {},
  1011. //搜索用户
  1012. searchUser() {
  1013. this.$refs['queryForm'].validate((valid) => {
  1014. if (valid) {
  1015. findUserByPhoneNumber(this.queryParams).then((res) => {
  1016. this.appUserInfo = res.data
  1017. })
  1018. }
  1019. })
  1020. },
  1021. handleAddClothFlaw(index) {
  1022. allClothAdjunct().then((res) => {
  1023. this.defaultList.clothAdjuncts = res.data;
  1024. this.defaultList.adjunct = ''
  1025. this.clothAdjuncts = res.data
  1026. this.addClothAdjunctOpen = true
  1027. this.selectClothItemIndex = index
  1028. this.addClothAdjuncts = this.orderClothItemDTOS[index].orderClothAdjunctDTOS.concat()
  1029. this.$forceUpdate()
  1030. })
  1031. },
  1032. handleAddClothPics(index) {
  1033. this.addClothPicOpen = true
  1034. this.selectClothItemIndex = index
  1035. this.addClothPics = this.orderClothItemDTOS[index].pics
  1036. },
  1037. handleClose(done) {
  1038. this.$confirm('确认关闭?')
  1039. .then((_) => {
  1040. done()
  1041. })
  1042. .catch((_) => {})
  1043. },
  1044. onClothAdjunctSelect(item) {
  1045. var isContains = false
  1046. for (let i = 0; i < this.addClothAdjuncts.length; i++) {
  1047. if (this.addClothAdjuncts[i].adjunctId == item.id) {
  1048. if (this.addClothAdjuncts[i].num >= 999) {
  1049. return
  1050. }
  1051. this.addClothAdjuncts[i].num++
  1052. isContains = true
  1053. break
  1054. }
  1055. }
  1056. if (!isContains) {
  1057. this.addClothAdjuncts.push({ adjunctId: item.id, num: 1, adjunctName: item.name })
  1058. }
  1059. },
  1060. removeClothAdjunct(index) {
  1061. this.addClothAdjuncts.splice(index, 1)
  1062. },
  1063. addClothAdjunctSubmit() {
  1064. console.log(this.orderClothItemDTOS[this.selectClothItemIndex])
  1065. this.orderClothItemDTOS[this.selectClothItemIndex].orderClothAdjunctDTOS = this.addClothAdjuncts.concat()
  1066. this.addClothAdjunctOpen = false
  1067. },
  1068. updateClothItem(index, tabIndex) {
  1069. if (tabIndex == 0) {
  1070. allList().then((res) => {
  1071. this.defaultList.type = ''
  1072. this.defaultList.clothTypes = res.data
  1073. this.clothTypes = res.data
  1074. this.selectClothItemIndex = index
  1075. this.form = { ...this.orderClothItemDTOS[index] }
  1076. this.isUpdateClothItem = true
  1077. this.addClothActiveTab = tabIndex
  1078. this.open = true
  1079. this.title = '修改衣物信息'
  1080. })
  1081. }
  1082. if (tabIndex == 2) {
  1083. allClothColor().then((res) => {
  1084. this.defaultList.color = ''
  1085. this.defaultList.clothColors = res.data
  1086. this.clothColors = res.data
  1087. this.selectClothItemIndex = index
  1088. this.form = { ...this.orderClothItemDTOS[index] }
  1089. this.isUpdateClothItem = true
  1090. this.addClothActiveTab = tabIndex
  1091. this.open = true
  1092. this.title = '修改衣物信息'
  1093. })
  1094. }
  1095. if (tabIndex == 3) {
  1096. allBrand().then((res) => {
  1097. this.defaultList.brand = ''
  1098. this.defaultList.clothBrands = res.data
  1099. this.clothBrands = res.data
  1100. this.selectClothItemIndex = index
  1101. this.form = { ...this.orderClothItemDTOS[index] }
  1102. this.isUpdateClothItem = true
  1103. this.addClothActiveTab = tabIndex
  1104. this.open = true
  1105. this.title = '修改衣服品牌'
  1106. })
  1107. }
  1108. if (tabIndex == 4) {
  1109. //修改瑕疵
  1110. allClothFlawType().then((res) => {
  1111. this.clothFlawTypes = res.data
  1112. allClothFlaw().then((res1) => {
  1113. this.defaultList.flaw = '';
  1114. this.defaultList.clothFlaws = res1.data
  1115. this.clothFlaws = res1.data
  1116. this.selectClothItemIndex = index
  1117. this.form = { ...this.orderClothItemDTOS[index] }
  1118. this.isUpdateClothItem = true
  1119. this.addClothActiveTab = tabIndex
  1120. this.open = true
  1121. this.title = '修改衣物信息'
  1122. })
  1123. })
  1124. }
  1125. },
  1126. addClothPicSubmit() {
  1127. this.orderClothItemDTOS[this.selectClothItemIndex].pics = this.addClothPics
  1128. if (this.isEmpty(this.addClothPics)) {
  1129. this.orderClothItemDTOS[this.selectClothItemIndex].picNum = 0
  1130. } else {
  1131. this.orderClothItemDTOS[this.selectClothItemIndex].picNum = this.addClothPics.split(',').length
  1132. }
  1133. // this.orderClothItemDTOS = this.orderClothItemDTOS.concat()
  1134. this.addClothPicOpen = false
  1135. // this.$forceUpdate()
  1136. // console.log(this.orderClothItemDTOS)
  1137. },
  1138. //复制衣服
  1139. handleCopyClothItem(index) {
  1140. this.orderClothItemDTOS.push({ ...this.orderClothItemDTOS[index] })
  1141. },
  1142. //修改洗衣方式
  1143. changeClothWashMode(index) {
  1144. listWashModePriceByClothId({ clothId: this.orderClothItemDTOS[index].id }).then((res) => {
  1145. this.clothWashModes = res.data
  1146. this.addClothWashModeOpen = true
  1147. this.selectClothItemIndex = index
  1148. })
  1149. },
  1150. //洗衣方式被选择
  1151. onClothWashModeSelect(index) {
  1152. this.orderClothItemDTOS[this.selectClothItemIndex].clothWashModeName = this.clothWashModes[index].washModeName
  1153. this.orderClothItemDTOS[this.selectClothItemIndex].clothWashModeId = this.clothWashModes[index].washModeId
  1154. this.orderClothItemDTOS[this.selectClothItemIndex].defaultPrice = this.clothWashModes[index].price
  1155. for (let i = 0; i < this.orderClothItemDTOS[this.selectClothItemIndex].clothTypeKeys.length; i++) {
  1156. if (this.orderClothItemDTOS[this.selectClothItemIndex].clothTypeKeys[i] == '1') {
  1157. this.orderClothItemDTOS[this.selectClothItemIndex].defaultPrice += this.orderClothItemDTOS[this.selectClothItemIndex].plusPrice
  1158. }
  1159. if (this.orderClothItemDTOS[this.selectClothItemIndex].clothTypeKeys[i] == '2') {
  1160. this.orderClothItemDTOS[this.selectClothItemIndex].defaultPrice += this.orderClothItemDTOS[this.selectClothItemIndex].silkPrice
  1161. }
  1162. if (this.orderClothItemDTOS[this.selectClothItemIndex].clothTypeKeys[i] == '3') {
  1163. this.orderClothItemDTOS[this.selectClothItemIndex].defaultPrice += this.orderClothItemDTOS[this.selectClothItemIndex].sheepPrice
  1164. }
  1165. if (this.orderClothItemDTOS[this.selectClothItemIndex].clothTypeKeys[i] == '4') {
  1166. this.orderClothItemDTOS[this.selectClothItemIndex].defaultPrice += this.orderClothItemDTOS[this.selectClothItemIndex].childPrice
  1167. }
  1168. }
  1169. this.addClothWashModeOpen = false
  1170. },
  1171. handleRemarkClothItem(index) {
  1172. this.selectClothItemIndex = index
  1173. this.clothRemark = this.orderClothItemDTOS[this.selectClothItemIndex].remark
  1174. this.addClothRemarkOpen = true
  1175. },
  1176. addClothRemarkSubmit() {
  1177. this.orderClothItemDTOS[this.selectClothItemIndex].remark = this.clothRemark
  1178. this.addClothRemarkOpen = false
  1179. },
  1180. //特殊价格处理
  1181. changeClothSpecialPriceEvent(index) {
  1182. this.selectClothItemIndex = index
  1183. this.clothSpecialForm = {}
  1184. var clothCrafts = []
  1185. this.clothCrafts.forEach((item) => {
  1186. var isSet = false
  1187. for (let i = 0; i < this.orderClothItemDTOS[this.selectClothItemIndex].orderClothCraftDTOS.length; i++) {
  1188. if (this.orderClothItemDTOS[this.selectClothItemIndex].orderClothCraftDTOS[i].clothCraftId == item.id) {
  1189. isSet = true
  1190. clothCrafts.push({
  1191. clothCraftId: item.id,
  1192. clothCraftName: item.craftName,
  1193. price: this.orderClothItemDTOS[this.selectClothItemIndex].orderClothCraftDTOS[i].price,
  1194. isSelect: true
  1195. })
  1196. break
  1197. }
  1198. }
  1199. if (!isSet) {
  1200. clothCrafts.push({
  1201. clothCraftId: item.id,
  1202. clothCraftName: item.craftName,
  1203. price: item.defaultPrice,
  1204. isSelect: false
  1205. })
  1206. }
  1207. })
  1208. var clothSpeeds = []
  1209. this.clothSpeeds.forEach((item) => {
  1210. var clothSpeed = { ...item }
  1211. clothSpeed.isSelect = clothSpeed.id == this.orderClothItemDTOS[this.selectClothItemIndex].clothSpeedId
  1212. clothSpeeds.push(clothSpeed)
  1213. })
  1214. this.clothSpecialForm.clothCrafts = clothCrafts
  1215. this.clothSpecialForm.clothSpeeds = clothSpeeds
  1216. this.clothSpecialForm.isHedging = this.orderClothItemDTOS[this.selectClothItemIndex].isHedging == 'Y'
  1217. this.clothSpecialForm.hedgingPrice = this.orderClothItemDTOS[this.selectClothItemIndex].hedgingPrice
  1218. this.clothSpecialForm.clothSpeedId = this.orderClothItemDTOS[this.selectClothItemIndex].clothSpeedId
  1219. this.clothSpecialForm.clothSpeedName = this.orderClothItemDTOS[this.selectClothItemIndex].clothSpeedName
  1220. this.setClothSpecialPriceOpen = true
  1221. console.log(this.clothSpecialForm)
  1222. },
  1223. changeClothDefaultPriceEvent(index) {
  1224. this.selectClothItemIndex = index
  1225. this.defaultPrice = this.orderClothItemDTOS[this.selectClothItemIndex].defaultPrice || null
  1226. this.setClothDefaultPriceOpen = true
  1227. },
  1228. /**
  1229. * 提交默认价格
  1230. */
  1231. setClothDefaultPriceSubmit() {
  1232. if (this.isEmpty(this.defaultPrice)) {
  1233. this.$message.error('请输入价格')
  1234. return
  1235. }
  1236. this.orderClothItemDTOS[this.selectClothItemIndex].defaultPrice = this.defaultPrice
  1237. this.orderClothItemDTOS[this.selectClothItemIndex].isCustomPrice = 'Y'
  1238. this.orderClothItemDTOS = this.orderClothItemDTOS.concat()
  1239. this.setClothDefaultPriceOpen = false
  1240. },
  1241. changeClothCraftSelect() {
  1242. console.log(this.clothSpecialForm)
  1243. this.$forceUpdate()
  1244. },
  1245. changeClothHedgingSelect(index) {
  1246. if (this.clothSpecialForm.isHedging) {
  1247. this.clothSpecialForm.clothSpeeds[1].isSelect = true
  1248. for (let i = 2; i < this.clothSpecialForm.clothSpeeds.length; i++) {
  1249. this.clothSpecialForm.clothSpeeds[i].isSelect = false
  1250. }
  1251. }
  1252. this.$forceUpdate()
  1253. },
  1254. changeClothSpeedSelect(index) {
  1255. if (index == 1 && this.clothSpecialForm.isHedging) {
  1256. this.clothSpecialForm.clothSpeeds[1].isSelect = true
  1257. } else {
  1258. if (this.clothSpecialForm.isHedging) {
  1259. this.clothSpecialForm.isHedging = false
  1260. }
  1261. for (let i = 1; i < this.clothSpecialForm.clothSpeeds.length; i++) {
  1262. if (i != index) {
  1263. this.clothSpecialForm.clothSpeeds[i].isSelect = false
  1264. }
  1265. }
  1266. }
  1267. this.$forceUpdate()
  1268. },
  1269. addClothSpecialSubmit() {
  1270. var param = {}
  1271. param.orderClothCraftDTOS = []
  1272. for (let i = 0; i < this.clothSpecialForm.clothCrafts.length; i++) {
  1273. if (this.clothSpecialForm.clothCrafts[i].isSelect) {
  1274. if (this.isEmpty(this.clothSpecialForm.clothCrafts[i].price)) {
  1275. this.$message.error(this.clothSpecialForm.clothCrafts[i].clothCraftName + '价格未设置')
  1276. return
  1277. }
  1278. param.orderClothCraftDTOS.push(this.clothSpecialForm.clothCrafts[i])
  1279. }
  1280. }
  1281. param.isHedging = this.clothSpecialForm.isHedging ? 'Y' : 'N'
  1282. param.hedgingPrice = this.clothSpecialForm.hedgingPrice
  1283. var isHighSpeed = false
  1284. for (let i = 1; i < this.clothSpecialForm.clothSpeeds.length; i++) {
  1285. if (this.clothSpecialForm.clothSpeeds[i].isSelect) {
  1286. isHighSpeed = true
  1287. param.clothSpeedId = this.clothSpecialForm.clothSpeeds[i].id
  1288. param.clothSpeedName = this.clothSpecialForm.clothSpeeds[i].name
  1289. param.clothSpeedMultiple = this.clothSpecialForm.clothSpeeds[i].multiple
  1290. break
  1291. }
  1292. }
  1293. if (!isHighSpeed) {
  1294. param.clothSpeedId = this.clothSpecialForm.clothSpeeds[0].id
  1295. param.clothSpeedMultiple = this.clothSpecialForm.clothSpeeds[0].multiple
  1296. }
  1297. this.orderClothItemDTOS[this.selectClothItemIndex] = { ...this.orderClothItemDTOS[this.selectClothItemIndex], ...param }
  1298. console.log(this.orderClothItemDTOS)
  1299. this.setClothSpecialPriceOpen = false
  1300. this.orderClothItemDTOS = this.orderClothItemDTOS.concat()
  1301. this.$forceUpdate()
  1302. },
  1303. async handleConfirmPay() {
  1304. if (this.orderClothItemDTOS.length == 0) {
  1305. this.$message.error('请先添加衣服')
  1306. return
  1307. }
  1308. if (!this.appUserInfo) {
  1309. this.$message.error('请先选择客户')
  1310. return
  1311. }
  1312. if (this.orderForm.isAppointment == 'Y' && this.isEmpty(this.orderForm.orderNo)) {
  1313. this.$message.error('请先输入预约订单号')
  1314. return
  1315. }
  1316. if (!this.orderForm.sendClothWay) {
  1317. this.$message.error('请先选取衣方式')
  1318. return
  1319. }
  1320. if (this.orderForm.isAppointment == 'Y') {
  1321. var res = await getInfoByOrderNo({ orderNo: this.orderForm.orderNo, appUserId: this.appUserInfo.id })
  1322. if (res.data == null) {
  1323. this.$message.error('未查询到预约订单')
  1324. return
  1325. }
  1326. // this.orderForm.sendClothWay = res.data.sendClothWay
  1327. }
  1328. //
  1329. var params = { appUserId: this.appUserInfo.id, discountWay: '2' }
  1330. var clothIds = []
  1331. this.orderClothItemDTOS.forEach((item) => {
  1332. clothIds.push(item.id)
  1333. })
  1334. params.clothIds = clothIds
  1335. this.orderForm.isSpecial = 'N'
  1336. this.orderForm.authCode = ''
  1337. this.orderForm.payType = ''
  1338. getDiscountByStoreId({ appUserId: this.appUserInfo.id }).then((res) => {
  1339. this.discountCouponVOS = res.data
  1340. params.discountWay = '0'
  1341. getCouponItemlistByAppUserId(params).then((res) => {
  1342. // console.log(res.data)
  1343. // res.data.forEach(item => {
  1344. // item.isUnique = 'N'
  1345. // })
  1346. this.deductCouponVOS = res.data
  1347. this.selectCoupons = []
  1348. this.orderClothItemDTOS.forEach((item, index) => {
  1349. item.index = index
  1350. item.deductAmount = 0
  1351. item.totalPrice = this.calculateClothSpecialPrice(index) + item.defaultPrice
  1352. })
  1353. delete this.orderForm.cashDeductAmount
  1354. delete this.orderForm.discountCouponId
  1355. delete this.orderForm.discountCoupon
  1356. this.confirmPayOpen = true
  1357. })
  1358. })
  1359. },
  1360. onCouponTabChange(tab, event) {
  1361. console.log('tab.index:' + tab.index)
  1362. // if(tab.index == '1'){
  1363. // this.$refs['couponRef'].focus()
  1364. // }
  1365. },
  1366. //计算某一件衣服的优惠金额,并配置到orderClothItemDTOS中
  1367. calculateClothDiscountAmount(index) {
  1368. var cloth = this.orderClothItemDTOS[index]
  1369. cloth.deductAmount = 0
  1370. this.selectCoupons.forEach((i) => {
  1371. var selectCloth = i.orderCouponClothDTOS.find((item) => item.clothIndex == cloth.index)
  1372. if (selectCloth) {
  1373. cloth.deductAmount = cloth.deductAmount + selectCloth.deductAmount
  1374. }
  1375. })
  1376. },
  1377. //<editor-folder desc="计算相关函数"/>
  1378. calculateClothSpecialPrice(index) {
  1379. // console.log('calculateClothSpecialPrice')
  1380. var specialPrice = 0
  1381. for (let i = 0; i < this.orderClothItemDTOS[index].orderClothCraftDTOS.length; i++) {
  1382. specialPrice += this.orderClothItemDTOS[index].orderClothCraftDTOS[i].price
  1383. }
  1384. if (this.orderClothItemDTOS[index].isHedging == 'Y') {
  1385. specialPrice += this.orderClothItemDTOS[index].hedgingPrice * 0.01
  1386. }
  1387. for (let i = 0; i < this.clothSpeeds.length; i++) {
  1388. if (this.orderClothItemDTOS[index].clothSpeedId == this.clothSpeeds[i].id) {
  1389. specialPrice += this.orderClothItemDTOS[index].defaultPrice * (this.clothSpeeds[i].multiple - 1)
  1390. break
  1391. }
  1392. }
  1393. // console.log('specialPrice:' + specialPrice)
  1394. return specialPrice
  1395. },
  1396. calculateClothName(index) {
  1397. var clothName = this.orderClothItemDTOS[index].name
  1398. console.log(this.orderClothItemDTOS[index].orderClothTypeDTOS)
  1399. this.orderClothItemDTOS[index].orderClothTypeDTOS.forEach((item) => {
  1400. clothName += '【' + item.clothTypeName + '】'
  1401. })
  1402. return clothName
  1403. },
  1404. calculateTotalPrice() {
  1405. var price = 0
  1406. for (let i = 0; i < this.orderClothItemDTOS.length; i++) {
  1407. price += this.calculateClothSpecialPrice(i) + this.orderClothItemDTOS[i].defaultPrice
  1408. }
  1409. return price
  1410. },
  1411. //</editor-folder>
  1412. //打开拍照弹框 调用摄像头
  1413. async handphotograph(index) {
  1414. this.selectClothItemIndex = index
  1415. if (this.orderClothItemDTOS[index].pics) {
  1416. let imgList = this.orderClothItemDTOS[index].pics.split(',')
  1417. imgList.forEach((item) => {
  1418. this.previewimgList.push(item)
  1419. this.photographimgList.push({
  1420. type: true,
  1421. src: item
  1422. })
  1423. })
  1424. }
  1425. this.photographType = true
  1426. try {
  1427. this.stream = await navigator.mediaDevices.getUserMedia({ video: true })
  1428. this.$refs.videoElement.srcObject = this.stream
  1429. this.videoType = false
  1430. } catch (error) {
  1431. this.$modal.msgError('无法访问摄像头')
  1432. // console.error("无法访问摄像头:", error);
  1433. // this.photographType = false
  1434. }
  1435. },
  1436. //点击拍照 处理成base64
  1437. async takePhoto() {
  1438. this.photoType = true
  1439. try {
  1440. const canvas = document.createElement('canvas')
  1441. const context = canvas.getContext('2d')
  1442. canvas.width = this.$refs.videoElement.videoWidth
  1443. canvas.height = this.$refs.videoElement.videoHeight
  1444. context.drawImage(this.$refs.videoElement, 0, 0, canvas.width, canvas.height)
  1445. const imageDataUrl = canvas.toDataURL('image/jpeg')
  1446. if (this.photographimgList.length >= 9) {
  1447. this.$modal.msgError('照片仅限上传9张')
  1448. this.photoType = false
  1449. return
  1450. }
  1451. let response = await fetch(imageDataUrl)
  1452. let blob = await response.blob() // 获取图片的 Blob 对象
  1453. let file = new File([blob], 'image.jpeg', { type: blob.type })
  1454. //创建form对象
  1455. let formdata = new FormData()
  1456. //通过append向form对象添加数据
  1457. formdata.append('file', file)
  1458. uploadOSS(formdata)
  1459. .then((res) => {
  1460. this.previewimgList.push(res.data.src)
  1461. this.photographimgList.push({
  1462. type: true,
  1463. src: res.data.src
  1464. })
  1465. this.photoType = false
  1466. })
  1467. .catch(() => {
  1468. // resolve(false);
  1469. this.photoType = false
  1470. })
  1471. // 上传照片或处理imageDataUrl
  1472. // this.uploadImage(imageDataUrl); // 调用上传接口或本地处理逻辑
  1473. } catch (error) {
  1474. this.photoType = false
  1475. // console.error("拍照失败:", error);
  1476. } finally {
  1477. // this.$refs.videoElement.srcObject.getTracks().forEach((track) => track.stop());
  1478. }
  1479. },
  1480. // 关闭拍照弹框后清除视频流
  1481. hidephotograph() {
  1482. const that = this
  1483. this.$confirm('是否确认关闭当前拍照功能?', '提示', {
  1484. confirmButtonText: '确定',
  1485. cancelButtonText: '取消',
  1486. type: 'warning'
  1487. })
  1488. .then(() => {
  1489. that.photographType = false
  1490. that.photographimgList = []
  1491. that.clothId = null
  1492. if (that.stream) {
  1493. that.stream.getTracks().forEach((track) => track.stop()) // 停止访问摄像头并释放资源
  1494. that.$refs.videoElement.srcObject = null // 清除视频流对象
  1495. }
  1496. })
  1497. .catch(() => {})
  1498. },
  1499. //删除照片
  1500. btn_remove(item, index) {
  1501. const that = this
  1502. this.$confirm('是否确认删除该照片?')
  1503. .then(function () {})
  1504. .then(() => {
  1505. that.photographimgList.splice(index, 1)
  1506. that.$modal.msgSuccess('删除成功')
  1507. })
  1508. .catch(() => {})
  1509. },
  1510. //保存图片
  1511. btn_submit() {
  1512. if (this.photographimgList.length < 1) {
  1513. this.$modal.msgError('请拍照上传后保存')
  1514. return
  1515. }
  1516. const srcString = this.photographimgList.map((obj) => obj.src).join(',')
  1517. this.orderClothItemDTOS[this.selectClothItemIndex].pics = srcString
  1518. if (!this.photographimgList.length) {
  1519. this.orderClothItemDTOS[this.selectClothItemIndex].picNum = 0
  1520. } else {
  1521. this.orderClothItemDTOS[this.selectClothItemIndex].picNum = this.photographimgList.length
  1522. }
  1523. this.$modal.msgSuccess('保存成功')
  1524. this.photographType = false
  1525. this.photographimgList = []
  1526. this.clothId = null
  1527. if (this.stream) {
  1528. this.stream.getTracks().forEach((track) => track.stop()) // 停止访问摄像头并释放资源
  1529. this.$refs.videoElement.srcObject = null // 清除视频流对象
  1530. }
  1531. }
  1532. }
  1533. }
  1534. </script>
  1535. <style scoped lang="scss">
  1536. .photo_content {
  1537. display: flex;
  1538. .video_content {
  1539. flex-shrink: 0;
  1540. width: 50%;
  1541. position: relative;
  1542. .loading {
  1543. position: absolute;
  1544. top: 0;
  1545. left: 0;
  1546. bottom: 0;
  1547. right: 0;
  1548. background-color: rgba(0, 0, 0, 0.8);
  1549. z-index: 10;
  1550. .el-button {
  1551. position: absolute;
  1552. top: 50%;
  1553. left: 50%;
  1554. transform: translate(-50%, -50%);
  1555. z-index: 15;
  1556. border: none;
  1557. color: #ffffff;
  1558. padding: 10px 20px;
  1559. }
  1560. }
  1561. .videoElement {
  1562. width: 100%;
  1563. height: auto;
  1564. }
  1565. }
  1566. .view {
  1567. flex: 1;
  1568. padding: 20px;
  1569. .btn_box {
  1570. display: flex;
  1571. .btn_upload {
  1572. margin: 0 10px;
  1573. }
  1574. }
  1575. .image_list {
  1576. margin-top: 20px;
  1577. .image_item {
  1578. display: inline-block;
  1579. margin: 0 10px 10px 0;
  1580. position: relative;
  1581. border-radius: 5px;
  1582. overflow: hidden;
  1583. .image_bottom {
  1584. position: absolute;
  1585. left: 0;
  1586. bottom: 0;
  1587. width: 100%;
  1588. // height: 25px;
  1589. // line-height: 25px;
  1590. background-color: rgba(255, 255, 255, 0.3);
  1591. text-align: center;
  1592. color: #fff;
  1593. cursor: pointer;
  1594. display: flex;
  1595. .el-button {
  1596. flex: 1;
  1597. }
  1598. }
  1599. }
  1600. }
  1601. }
  1602. }
  1603. </style>