searchCloth.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  1. <template>
  2. <div class="app-container">
  3. <el-card class="search-wrapper" shadow="never">
  4. <el-form :model="queryParams" ref="queryForm" @submit.native.prevent :inline="true" v-show="showSearch" label-width="68px">
  5. <el-form-item prop="flowStatus">
  6. <el-select v-model="queryParams.flowStatus" placeholder="请选择衣服状态" clearable>
  7. <el-option key="0" label="待入厂" value="0" />
  8. <el-option key="1" label="清洗中" value="1" />
  9. <el-option key="2" label="已检查" value="2" />
  10. <el-option key="3" label="已出厂" value="3" />
  11. <el-option key="4" label="已上挂" value="4" />
  12. <el-option key="5" label="已取衣" value="5" />
  13. <el-option key="-1" label="已取消" value="-1" />
  14. </el-select>
  15. </el-form-item>
  16. <el-form-item>
  17. <el-date-picker v-model="createTimeRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="下单日期" end-placeholder="结束日期"></el-date-picker>
  18. </el-form-item>
  19. <el-form-item prop="washCode">
  20. <el-input v-model="queryParams.washCode" placeholder="请输入衣服条码" clearable @keyup.enter.native="handleQuery" />
  21. </el-form-item>
  22. <el-form-item prop="clothItemName">
  23. <el-input v-model="queryParams.clothItemName" placeholder="请输入衣服名称" clearable @keyup.enter.native="handleQuery" />
  24. </el-form-item>
  25. <el-form-item>
  26. <el-date-picker v-model="takeClothTimeRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="取衣日期" end-placeholder="结束日期"></el-date-picker>
  27. </el-form-item>
  28. <el-form-item prop="appUserPhoneNumber">
  29. <el-input v-model="queryParams.appUserPhoneNumber" placeholder="请输入客户电话" clearable @keyup.enter.native="handleQuery" />
  30. </el-form-item>
  31. <el-form-item prop="clothHangerId">
  32. <el-input v-model="queryParams.clothHangerId" placeholder="请输入挂衣号" clearable @keyup.enter.native="handleQuery" />
  33. </el-form-item>
  34. <el-form-item>
  35. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  36. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  37. </el-form-item>
  38. </el-form>
  39. </el-card>
  40. <el-row :gutter="10" class="mb8">
  41. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  42. </el-row>
  43. <Page uri="/mapi/order/clothItem/list" :request-params="queryParams" ref="pagination">
  44. <el-table-column label="衣物条码" align="center" prop="washCode" fixed="left" min-width="120"/>
  45. <el-table-column label="衣服名称" align="center" prop="clothItemName" min-width="120"/>
  46. <el-table-column label="衣物照片" align="center" width="120">
  47. <template slot-scope="scope">
  48. <div class="cloth-photos" v-if="scope.row.pics">
  49. <el-image
  50. v-for="(pic, index) in scope.row.pics.split(',')"
  51. :key="index"
  52. :src="pic"
  53. :preview-src-list="scope.row.pics.split(',')"
  54. fit="cover"
  55. class="cloth-photo"
  56. @click="handlePreview(scope.row.pics.split(','))"
  57. >
  58. <div slot="error" class="image-slot">
  59. <i class="el-icon-picture-outline"></i>
  60. </div>
  61. </el-image>
  62. </div>
  63. <span v-else>暂无照片</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="是否重洗" align="center" prop="repeatCount">
  67. <template slot-scope="scope">
  68. <span v-if="scope.row.repeatCount && scope.row.repeatCount > 0" style="color: red"> 重洗 {{ scope.row.repeatCount }} 次 </span>
  69. <span v-else> 否 </span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="客户信息" align="center" prop="appUserName" width="150">
  73. <template slot-scope="scope">
  74. <span>{{ scope.row.appUserName ? scope.row.appUserName : '--' }} </span>
  75. <br />
  76. <span>{{ scope.row.appUserPhoneNumber ? scope.row.appUserPhoneNumber : '' }}</span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="颜色" align="center">
  80. <template slot-scope="scope">
  81. <template v-for="(item, index) in scope.row.orderClothColors">
  82. {{ index == 0 ? item.clothColorName : ',' + item.clothColorName }}
  83. </template>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="附件" align="center" min-width="120">
  87. <template slot-scope="scope">
  88. <template v-for="(item, index) in scope.row.orderClothAdjuncts">
  89. {{ index == 0 ? item.adjunctName : ',' + item.adjunctName }}
  90. </template>
  91. <span v-if="!scope.row.orderClothAdjuncts">暂无</span>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="挂衣号" align="center">
  95. <template slot-scope="scope">
  96. <span v-if="scope.row.clothHanger">
  97. {{ scope.row.clothHanger.name + '#' + scope.row.clothHangerCode }}
  98. </span>
  99. <span v-else>暂无</span>
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="衣服状态" align="center" prop="flowStatus" width="80">
  103. <template slot-scope="scope">
  104. <el-tag type="danger" v-if="scope.row.refundId !=null">已撤销</el-tag>
  105. <dict-tag v-else :options="dict.type.order_cloth_flow_status" :value="scope.row.flowStatus" />
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="订单编号" align="center" prop="orderNo" min-width="120" />
  109. <el-table-column label="订单状态" align="center" prop="flowStatus" width="80">
  110. <template slot-scope="scope">
  111. <dict-tag :options="dict.type.cloth_order_status" :value="scope.row.orderStatus" />
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="下单时间" align="center" prop="createTime" min-width="90"/>
  115. <el-table-column label="取衣时间" align="center" prop="sendClothTime" min-width="90">
  116. <template slot-scope="scope">
  117. <span v-if="scope.row.sendClothTime">
  118. {{ scope.row.clothHanger.sendClothTime }}
  119. </span>
  120. <span v-else>--</span>
  121. </template>
  122. </el-table-column>
  123. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="150">
  124. <template slot-scope="scope">
  125. <el-button type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">详情</el-button>
  126. <el-button type="text" icon="el-icon-camera" @click="handphotograph(scope.row)">拍照</el-button>
  127. <el-button type="text" icon="el-icon-printer" v-if="userInfoVO.userType != '00'" @click="btn_pointer_label(scope.row)">标签打印</el-button>
  128. </template>
  129. </el-table-column>
  130. </Page>
  131. <!-- 添加或修改洗衣订单衣服明细对话框 -->
  132. <el-dialog :title="title" :visible.sync="open" size="50%" append-to-body>
  133. <el-row :gutter="15" style="margin-bottom: 80px; margin-left: 20px; width: calc(100% - 20px)">
  134. <el-col :span="24">
  135. <el-descriptions class="margin-top" :column="2" border>
  136. <el-descriptions-item>
  137. <template slot="label"> 衣物条码 </template>
  138. {{ form.washCode }}
  139. </el-descriptions-item>
  140. <el-descriptions-item>
  141. <template slot="label"> 洗衣单号 </template>
  142. {{ form.orderNo }}
  143. </el-descriptions-item>
  144. <el-descriptions-item>
  145. <template slot="label"> 衣服名称 </template>
  146. {{ form.clothItemName }}
  147. </el-descriptions-item>
  148. <el-descriptions-item>
  149. <template slot="label"> 颜色 </template>
  150. <el-tag size="small" v-for="(item, index) in form.orderClothColors" :key="index" style="margin-right: 10px; margin-bottom: 2.5px; margin-top: 2.5px">{{ item.clothColorName }}</el-tag>
  151. </el-descriptions-item>
  152. <el-descriptions-item>
  153. <template slot="label"> 瑕疵 </template>
  154. <el-tag size="small" v-for="(item, index) in form.orderClothFlaws" :key="index" style="margin-right: 10px; margin-bottom: 2.5px; margin-top: 2.5px">{{ item.clothFlawName }}</el-tag>
  155. </el-descriptions-item>
  156. <el-descriptions-item>
  157. <template slot="label"> 特殊处理 </template>
  158. <el-tag size="small" v-for="(item, index) in form.orderClothCrafts" :key="index" style="margin-right: 10px; margin-bottom: 2.5px; margin-top: 2.5px">{{ item.clothCraftName + '(¥' + item.price + ')' }}</el-tag>
  159. </el-descriptions-item>
  160. <el-descriptions-item>
  161. <template slot="label"> 附件 </template>
  162. <el-tag size="small" v-for="(item, index) in form.orderClothAdjuncts" :key="index" style="margin-right: 10px; margin-bottom: 2.5px; margin-top: 2.5px">{{ item.adjunctName }}</el-tag>
  163. </el-descriptions-item>
  164. <el-descriptions-item>
  165. <template slot="label"> 挂衣号 </template>
  166. </el-descriptions-item>
  167. <el-descriptions-item>
  168. <template slot="label"> 预计取衣 </template>
  169. </el-descriptions-item>
  170. <el-descriptions-item>
  171. <template slot="label"> 衣服状态 </template>
  172. <dict-tag :options="dict.type.order_cloth_flow_status" :value="form.flowStatus" />
  173. </el-descriptions-item>
  174. <el-descriptions-item>
  175. <template slot="label"> 照片 </template>
  176. <template v-if="form.pics">
  177. <el-image v-for="(item, index) in form.pics.split(',')" :key="index" style="width: 100px; height: 100px; margin-right: 10px; margin-top: 2.5px; margin-bottom: 2.5px" :src="item" :preview-src-list="form.pics.split(',')"> </el-image>
  178. </template>
  179. </el-descriptions-item>
  180. </el-descriptions>
  181. </el-col>
  182. <el-col :span="24" style="margin-top: 10px">
  183. <el-table :data="form.orderClothAdjuncts" :v-if="form.orderClothAdjuncts" fit highlight-current-row border stripe>
  184. <el-table-column label="附件条码" align="center" prop="adjunctNo" />
  185. <el-table-column label="附件名称" align="center" prop="adjunctName" />
  186. <el-table-column label="附件状态" align="center" prop="flowStatus">
  187. <template slot-scope="scope">
  188. <dict-tag :options="dict.type.order_cloth_flow_status" :value="scope.row.flowStatus" />
  189. </template>
  190. </el-table-column>
  191. </el-table>
  192. </el-col>
  193. <el-col :span="24" style="margin-top: 10px">
  194. <el-table :data="flowRecords" fit highlight-current-row border stripe>
  195. <el-table-column label="操作" align="center">
  196. <template slot-scope="scope">
  197. <dict-tag :options="dict.type.order_cloth_flow_action" :value="scope.row.flowStatus" />
  198. </template>
  199. </el-table-column>
  200. <el-table-column label="时间" align="center" prop="createTime" />
  201. <el-table-column label="操作人" align="center" prop="operateName" />
  202. <el-table-column label="单位" align="center" prop="operateOrgName" />
  203. </el-table>
  204. </el-col>
  205. </el-row>
  206. <div slot="footer" class="dialog-footer">
  207. <!-- <el-button type="primary" @click="submitForm" style="margin-left: 5%">提交</el-button>-->
  208. <el-button @click="cancel" style="margin-left: 5%">关 闭</el-button>
  209. </div>
  210. </el-dialog>
  211. <!-- 拍照上传 -->
  212. <el-dialog title="拍照上传" :visible.sync="photographType" :before-close="hidephotograph" width="55%">
  213. <div class="photo_content">
  214. <div class="video_content">
  215. <div class="loading" v-if="videoType">
  216. <el-button type="text" :loading="true" disabled>加载中请稍后</el-button>
  217. </div>
  218. <video class="videoElement" ref="videoElement" autoplay></video>
  219. </div>
  220. <div class="view">
  221. <div class="btn_box">
  222. <el-button class="btn_photo" :loading="photoType" :disabled="photoType" icon="el-icon-camera" type="primary" plain @click="takePhoto" v-if="!videoType">拍照上传</el-button>
  223. <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">
  224. <el-button icon="el-icon-folder" plain type="primary">上传本地文件</el-button>
  225. </el-upload>
  226. </div>
  227. <div class="image_list" v-if="photographimgList.length">
  228. <div class="image_item" v-for="(item, index) in photographimgList" :key="index">
  229. <el-image style="width: 120px; height: 120px" :src="item.src ? item.src : item.url" :preview-src-list="previewimgList"> </el-image>
  230. <div class="image_bottom">
  231. <el-button type="danger" icon="el-icon-delete" @click="btn_remove(item, index)"></el-button>
  232. <el-button v-if="item.type" type="success" icon="el-icon-check"></el-button>
  233. </div>
  234. </div>
  235. </div>
  236. <el-empty :image-size="200" v-else></el-empty>
  237. </div>
  238. </div>
  239. <span slot="footer" class="dialog-footer">
  240. <el-button @click="hidephotograph">关 闭</el-button>
  241. <el-button type="primary" @click="btn_submit">保 存</el-button>
  242. </span>
  243. </el-dialog>
  244. </div>
  245. </template>
  246. <script>
  247. import { listOrderClothItem, getClothItem, delClothItem, addClothItem, updateClothItem, updateClothItemStatus } from '@/api/order/clothItem'
  248. import { listOrderClothFlowRecordByOrderClothId } from '../../../api/order/clothItemFlowRecord'
  249. import { uploadBase64OSS, uploadOSS, saveOrderClothPics } from '@/api/upload'
  250. import { getLodop } from '@/utils/lodopUtils'
  251. export default {
  252. name: 'ClothItem',
  253. dicts: ['sys_yes_no', 'order_cloth_flow_status', 'cloth_order_status' ,'order_cloth_flow_action'],
  254. data() {
  255. return {
  256. uploadAction: `${process.env.VUE_APP_BASE_API}` + '/common/uploadOSS',
  257. // 遮罩层
  258. loading: true,
  259. // 选中数组
  260. ids: [],
  261. // 非单个禁用
  262. single: true,
  263. // 非多个禁用
  264. multiple: true,
  265. // 显示搜索条件
  266. showSearch: true,
  267. // 总条数
  268. total: 0,
  269. // 洗衣订单衣服明细表格数据
  270. clothItemList: [],
  271. // 弹出层标题
  272. title: '',
  273. // 是否显示弹出层
  274. open: false,
  275. // 查询参数
  276. queryParams: {
  277. clothItemName: null,
  278. washCode: null,
  279. clothHangerId: null
  280. },
  281. createTimeRange: [],
  282. takeClothTimeRange: [],
  283. // 表单参数
  284. form: {},
  285. flowRecords: [],
  286. // 表单校验
  287. rules: {},
  288. photographType: false,
  289. photographimgList: [],
  290. previewimgList: [],
  291. uploadList: [],
  292. photoLoading: true,
  293. clothId: null,
  294. stream: null,
  295. fileType: ['png', 'jpg', 'jpeg'],
  296. number: 0,
  297. videoType: true,
  298. photoType: false,
  299. LODOP: null,
  300. number: 1,
  301. pointerList: [],
  302. userInfoVO: null
  303. }
  304. },
  305. created() {
  306. this.userInfoVO = this.getUserInfo()
  307. this.getList()
  308. },
  309. mounted() {
  310. this.number = 1
  311. const printerTime = setInterval(() => {
  312. this.LODOP = getLodop()
  313. this.number++
  314. if (this.number == 25) {
  315. clearInterval(printerTime)
  316. }
  317. if (this.LODOP) {
  318. clearInterval(printerTime)
  319. }
  320. }, 200)
  321. this.pointerList = JSON.parse(this.$cache.local.get('printerSeting'))
  322. },
  323. methods: {
  324. // 上传前校检格式和大小
  325. handleBeforeUpload(file) {
  326. console.log(file)
  327. // 校检文件类型
  328. if (this.fileType) {
  329. const fileName = file.name.split('.')
  330. const fileExt = fileName[fileName.length - 1]
  331. const isTypeOk = this.fileType.indexOf(fileExt) >= 0
  332. if (!isTypeOk) {
  333. this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join('/')}格式文件!`)
  334. return false
  335. }
  336. }
  337. // 校检文件大小
  338. const isLt = file.size / 1024 / 1024 < 3
  339. if (!isLt) {
  340. this.$message.error(`上传文件大小不能超过 3MB!`)
  341. return false
  342. }
  343. this.$modal.loading('正在上传文件,请稍候...')
  344. // this.number++;
  345. return true
  346. },
  347. handleUploadSuccess(res, file) {
  348. if (res.code === 200) {
  349. this.previewimgList.push(res.data.src)
  350. this.uploadList.push({ name: res.data.fileName, url: res.data.src })
  351. this.uploadedSuccessfully()
  352. } else {
  353. // this.number--;
  354. this.$modal.closeLoading()
  355. this.$modal.msgError(res.msg)
  356. this.$refs.fileUpload.handleRemove(file)
  357. this.uploadedSuccessfully()
  358. }
  359. },
  360. handleUploadError() {
  361. this.$modal.msgError('上传文件失败,请重试')
  362. this.$modal.closeLoading()
  363. },
  364. // 上传结束处理
  365. uploadedSuccessfully() {
  366. if (this.uploadList.length) {
  367. // this.fileList = this.fileList.concat(this.uploadList);
  368. this.uploadList.forEach((item) => {
  369. this.photographimgList.push({
  370. src: item.url,
  371. fileName: item.fileName,
  372. type: true
  373. })
  374. })
  375. this.uploadList = []
  376. // this.number = 0;
  377. this.$modal.closeLoading()
  378. this.getuploadState()
  379. }
  380. },
  381. //根据上传文件状态判断显示
  382. getuploadState() {
  383. // 初始状态值
  384. let state = true
  385. // 判断数组中的所有元素是否都为true
  386. if (this.photographimgList.every((item) => item.type === true)) {
  387. state = false
  388. } else {
  389. state = true
  390. }
  391. return state
  392. },
  393. /** 查询洗衣订单衣服明细列表 */
  394. getList() {
  395. this.loading = true
  396. if (null != this.createTimeRange && '' != this.createTimeRange) {
  397. this.queryParams['beginCreateTime'] = this.createTimeRange[0]
  398. this.queryParams['endCreateTime'] = this.createTimeRange[1]
  399. } else {
  400. delete this.queryParams.beginCreateTime
  401. delete this.queryParams.endCreateTime
  402. }
  403. if (null != this.takeClothTimeRange && '' != this.takeClothTimeRange) {
  404. this.queryParams['beginTakeClothTime'] = this.takeClothTimeRange[0]
  405. this.queryParams['endTakeClothTime'] = this.takeClothTimeRange[1]
  406. } else {
  407. delete this.queryParams.beginTakeClothTime
  408. delete this.queryParams.endTakeClothTime
  409. }
  410. this.$nextTick(() => {
  411. this.$refs.pagination.handleSearch(true)
  412. })
  413. },
  414. // 取消按钮
  415. cancel() {
  416. this.open = false
  417. this.reset()
  418. },
  419. // 表单重置
  420. reset() {
  421. this.form = {
  422. id: null,
  423. orderId: null,
  424. clothItemId: null,
  425. clothItemName: null,
  426. clothSpeedId: null,
  427. clothSpeedName: null,
  428. clothMultiple: null,
  429. clothWashDayNum: null,
  430. price: null,
  431. clothNum: null,
  432. clothWashModeId: null,
  433. clothWashModeName: null,
  434. pics: null,
  435. washCode: null,
  436. clothHangerId: null,
  437. isHedging: null,
  438. hedgingPrice: null,
  439. createById: null,
  440. createBy: null,
  441. createTime: null,
  442. updateById: null,
  443. updateBy: null,
  444. updateTime: null,
  445. remark: null
  446. }
  447. this.resetForm('form')
  448. },
  449. /** 搜索按钮操作 */
  450. handleQuery() {
  451. this.queryParams.pageNum = 1
  452. this.getList()
  453. },
  454. /** 重置按钮操作 */
  455. resetQuery() {
  456. this.resetForm('queryForm')
  457. this.handleQuery()
  458. },
  459. // 多选框选中数据
  460. handleSelectionChange(selection) {
  461. this.ids = selection.map((item) => item.id)
  462. this.single = selection.length !== 1
  463. this.multiple = !selection.length
  464. },
  465. /** 新增按钮操作 */
  466. handleAdd() {
  467. this.reset()
  468. this.open = true
  469. this.title = '添加洗衣订单衣服明细'
  470. },
  471. /** 修改按钮操作 */
  472. handleUpdate(row) {
  473. this.reset()
  474. this.flowRecords = []
  475. const id = row.id || this.ids
  476. getClothItem(id).then((response) => {
  477. this.form = response.data
  478. this.open = true
  479. this.title = '衣物详情'
  480. listOrderClothFlowRecordByOrderClothId({ orderClothId: id }).then((res) => {
  481. this.flowRecords = res.data
  482. })
  483. })
  484. },
  485. /** 提交按钮 */
  486. submitForm() {
  487. this.$refs['form'].validate((valid) => {
  488. if (valid) {
  489. if (this.form.id != null) {
  490. updateClothItem(this.form).then((response) => {
  491. this.$modal.msgSuccess('修改成功')
  492. this.open = false
  493. this.getList()
  494. })
  495. } else {
  496. addClothItem(this.form).then((response) => {
  497. this.$modal.msgSuccess('新增成功')
  498. this.open = false
  499. this.getList()
  500. })
  501. }
  502. }
  503. })
  504. },
  505. /** 删除按钮操作 */
  506. handleDelete(row) {
  507. const ids = row.id || this.ids
  508. this.$modal
  509. .confirm('是否确认删除洗衣订单衣服明细编号为"' + ids + '"的数据项?')
  510. .then(function () {
  511. return delClothItem(ids)
  512. })
  513. .then(() => {
  514. this.getList()
  515. this.$modal.msgSuccess('删除成功')
  516. })
  517. .catch(() => {})
  518. },
  519. /** 导出按钮操作 */
  520. handleExport() {
  521. this.download(
  522. 'mapi/order/clothItem/export',
  523. {
  524. ...this.queryParams
  525. },
  526. `clothItem_${new Date().getTime()}.xlsx`
  527. )
  528. },
  529. checkClose(done) {
  530. this.$confirm('是否关闭表单,关闭后数据将丢失?')
  531. .then(function () {
  532. done()
  533. })
  534. .then(() => {})
  535. .catch(() => {})
  536. },
  537. //打开拍照弹框 调用摄像头
  538. async handphotograph(row) {
  539. let objform = Object.assign({}, row)
  540. this.clothId = objform.id
  541. if (objform.pics) {
  542. let imgList = objform.pics.split(',')
  543. imgList.forEach((item) => {
  544. this.previewimgList.push(item)
  545. this.photographimgList.push({
  546. type: true,
  547. src: item
  548. })
  549. })
  550. }
  551. this.photographType = true
  552. try {
  553. this.stream = await navigator.mediaDevices.getUserMedia({ video: true })
  554. this.$refs.videoElement.srcObject = this.stream
  555. this.videoType = false
  556. } catch (error) {
  557. this.$modal.msgError('无法访问摄像头')
  558. // console.error("无法访问摄像头:", error);
  559. // this.photographType = false
  560. }
  561. },
  562. //点击拍照 处理成base64
  563. async takePhoto() {
  564. this.photoType = true
  565. try {
  566. const canvas = document.createElement('canvas')
  567. const context = canvas.getContext('2d')
  568. canvas.width = this.$refs.videoElement.videoWidth
  569. canvas.height = this.$refs.videoElement.videoHeight
  570. context.drawImage(this.$refs.videoElement, 0, 0, canvas.width, canvas.height)
  571. const imageDataUrl = canvas.toDataURL('image/jpeg')
  572. if (this.photographimgList.length >= 9) {
  573. this.$modal.msgError('照片仅限上传9张')
  574. this.photoType = false
  575. return
  576. }
  577. let response = await fetch(imageDataUrl)
  578. let blob = await response.blob() // 获取图片的 Blob 对象
  579. let file = new File([blob], 'image.jpeg', { type: blob.type })
  580. //创建form对象
  581. let formdata = new FormData()
  582. //通过append向form对象添加数据
  583. formdata.append('file', file)
  584. uploadOSS(formdata)
  585. .then((res) => {
  586. this.previewimgList.push(res.data.src)
  587. this.photographimgList.push({
  588. type: true,
  589. src: res.data.src
  590. })
  591. this.photoType = false
  592. })
  593. .catch(() => {
  594. // resolve(false);
  595. this.photoType = false
  596. })
  597. // 上传照片或处理imageDataUrl
  598. // this.uploadImage(imageDataUrl); // 调用上传接口或本地处理逻辑
  599. } catch (error) {
  600. this.photoType = false
  601. // console.error("拍照失败:", error);
  602. } finally {
  603. // this.$refs.videoElement.srcObject.getTracks().forEach((track) => track.stop());
  604. }
  605. },
  606. // 关闭拍照弹框后清除视频流
  607. hidephotograph() {
  608. const that = this
  609. this.$confirm('是否确认关闭当前拍照功能?', '提示', {
  610. confirmButtonText: '确定',
  611. cancelButtonText: '取消',
  612. type: 'warning'
  613. })
  614. .then(() => {
  615. that.photographType = false
  616. that.photographimgList = []
  617. that.clothId = null
  618. if (that.stream) {
  619. that.stream.getTracks().forEach((track) => track.stop()) // 停止访问摄像头并释放资源
  620. that.$refs.videoElement.srcObject = null // 清除视频流对象
  621. }
  622. })
  623. .catch(() => {})
  624. },
  625. //删除照片
  626. btn_remove(item, index) {
  627. const that = this
  628. this.$confirm('是否确认删除该照片?')
  629. .then(function () {})
  630. .then(() => {
  631. that.photographimgList.splice(index, 1)
  632. that.$modal.msgSuccess('删除成功')
  633. })
  634. .catch(() => {})
  635. },
  636. //保存图片
  637. btn_submit() {
  638. let _type = false
  639. if (this.photographimgList.length < 1) {
  640. this.$modal.msgError('请拍照上传后保存')
  641. return
  642. }
  643. const srcString = this.photographimgList.map((obj) => obj.src).join(',')
  644. saveOrderClothPics({
  645. id: this.clothId,
  646. pics: srcString
  647. }).then((response) => {
  648. this.$modal.msgSuccess('保存图片成功')
  649. this.photographType = false
  650. this.photographimgList = []
  651. this.clothId = null
  652. this.getList()
  653. if (this.stream) {
  654. this.stream.getTracks().forEach((track) => track.stop()) // 停止访问摄像头并释放资源
  655. this.$refs.videoElement.srcObject = null // 清除视频流对象
  656. }
  657. })
  658. },
  659. //标签打印
  660. btn_pointer_label(row) {
  661. if (!this.LODOP) {
  662. this.$modal.msgError('请安装打印机软件')
  663. return
  664. }
  665. let p_name = ''
  666. this.pointerList.forEach((pointer) => {
  667. if (pointer.printType == 2) {
  668. p_name = pointer.printName
  669. }
  670. })
  671. console.log("AAAA", row)
  672. this.labelPrinter(this.LODOP, row, p_name)
  673. }
  674. }
  675. }
  676. </script>
  677. <style scoped lang="scss">
  678. .photo_content {
  679. display: flex;
  680. .video_content {
  681. flex-shrink: 0;
  682. width: 50%;
  683. position: relative;
  684. .loading {
  685. position: absolute;
  686. top: 0;
  687. left: 0;
  688. bottom: 0;
  689. right: 0;
  690. background-color: rgba(0, 0, 0, 0.8);
  691. z-index: 10;
  692. .el-button {
  693. position: absolute;
  694. top: 50%;
  695. left: 50%;
  696. transform: translate(-50%, -50%);
  697. z-index: 15;
  698. border: none;
  699. color: #ffffff;
  700. padding: 10px 20px;
  701. }
  702. }
  703. .videoElement {
  704. width: 100%;
  705. height: auto;
  706. }
  707. }
  708. .view {
  709. flex: 1;
  710. padding: 20px;
  711. .btn_box {
  712. display: flex;
  713. .btn_upload {
  714. margin: 0 10px;
  715. }
  716. }
  717. .image_list {
  718. margin-top: 20px;
  719. .image_item {
  720. display: inline-block;
  721. margin: 0 10px 10px 0;
  722. position: relative;
  723. border-radius: 5px;
  724. overflow: hidden;
  725. .image_bottom {
  726. position: absolute;
  727. left: 0;
  728. bottom: 0;
  729. width: 100%;
  730. // height: 25px;
  731. // line-height: 25px;
  732. background-color: rgba(255, 255, 255, 0.3);
  733. text-align: center;
  734. color: #fff;
  735. cursor: pointer;
  736. display: flex;
  737. .el-button {
  738. flex: 1;
  739. }
  740. }
  741. }
  742. }
  743. }
  744. }
  745. </style>