| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- <template>
- <view class="follow_wrap">
- <u-navbar placeholder :autoBack="true" title="上传录音" @rightClick="handleNavSaveClick">
- <view class="u-nav-slot" slot="right">
- 保存
- </view>
- </u-navbar>
- <view class="form_wrap">
- <u--form labelPosition="left" labelWidth="80" :model="form" :rules="rules" ref="form" class="form_wrap">
- <u-form-item label="线索id">
- {{ clueDetail && clueDetail.id ? clueDetail.id : "-" }}
- </u-form-item>
- <u-form-item label="线索名称">
- {{ clueDetail && clueDetail.name ? clueDetail.name : "-" }}
- </u-form-item>
- <u-form-item label="操作人">
- {{ userInfo.nickName }}
- </u-form-item>
- <u-form-item label="主叫号码" prop="caller">
- <u--input clearable v-model="form.caller" placeholder="请输入主叫号码"></u--input>
- </u-form-item>
- <u-form-item label="被叫号码" prop="callee">
- <u--input clearable v-model="form.callee" placeholder="请输入被叫号码"></u--input>
- </u-form-item>
- <u-form-item label="录音" prop="fileUrl">
- <ld-select :list="filelist" label-key="fileName" value-key="filePath" placeholder="请选择"
- v-model="form.fileUrl" :border="false" @change="handleFileChange"></ld-select>
- <u-icon slot="right" name="arrow-right"></u-icon>
- </u-form-item>
- <u-form-item label="备注" prop="remark">
- <u--textarea v-model="form.remark" placeholder="请输入内容" count confirmType="done" maxlength="500">
- </u--textarea>
- </u-form-item>
- </u--form>
- </view>
- <!-- 录音确认对话框 -->
- <u-popup :show="showConfirmDialog" mode="center" :closeable="false" :closeOnClickOverlay="false">
- <view class="confirm-dialog">
- <view class="dialog-title">确认录音</view>
- <view class="dialog-content">
- <view class="file-info">
- <view class="file-name">{{ selectedFile.fileName }}</view>
- </view>
- <view class="play-section">
- <audio :src="selectedFile.filePath" controls class="audio-player"></audio>
- </view>
- </view>
- <view class="dialog-buttons">
- <u-button text="取消" @click="cancelConfirm" :plain="true"></u-button>
- <u-button text="确认" @click="confirmUpload" type="primary"></u-button>
- </view>
- </view>
- </u-popup>
- <!-- <drag-button :isDock="true" /> -->
- </view>
- </template>
- <script>
- export default {
- computed: {
- userInfo() {
- return this.$store.state.user.userInfo;
- },
- filelist() {
- return this.$store.state.call.filelist;
- },
- storeForm() {
- return this.$store.state.call.form;
- },
- },
- data() {
- return {
- rules: {
- 'caller': {
- type: 'string',
- required: true,
- message: '请输入内容',
- trigger: ['blur', 'change']
- },
- 'callee': {
- type: 'string',
- required: true,
- message: '请输入内容',
- trigger: ['blur', 'change']
- },
- 'fileUrl': {
- type: 'string',
- required: true,
- message: '请输入内容',
- trigger: ['blur', 'change']
- },
- },
- form: {
- clueId: undefined,
- remark: '',
- fileUrl: undefined,
- fileName: undefined,
- type: '3',
- list: [],
- caller: '',
- callee: ''
- },
- clueDetail: {},
- // 对话框相关状态
- showConfirmDialog: false,
- selectedFile: {
- filePath: '',
- fileName: ''
- },
- }
- },
- methods: {
- initFormFromStore() {
- const storeFormData = this.storeForm;
- this.form = {
- ...this.form,
- caller: storeFormData.caller || '',
- callee: storeFormData.callee || '',
- fileUrl: storeFormData.fileUrl,
- fileName: storeFormData.fileName,
- remark: storeFormData.remark,
- type: storeFormData.type,
- list: storeFormData.list
- };
- uni.$u.api.getClueMainInfoById({ id: this.form.clueId }).then(({ data }) => {
- this.clueDetail = data;
- })
- if (!this.form.callee) {
- // 没有准备被叫号码 直接去查线索的telephone
- this.form.callee = this.clueDetail.telephone;
- };
- if (!this.form.caller) {
- // 没有准备主叫号码 直接去尝试获取
- this.$store.dispatch("call/getUserPhoneNumber").then(phone => {
- this.form.caller = phone;
- })
- }
- if (storeFormData.fileUrl) {
- // 初始化带了fileUrl 说明是从监听那边跳转的
- this.handleFileChange({ filePath: storeFormData.fileUrl, fileName: storeFormData.fileName });
- }
- this.$store.dispatch("call/resetForm");
- },
- handleFileChange(file) {
- // {
- // "filePath": "/storage/emulated/0/Recordings/Record/Call/15099989786 2025-11-11 09-41-57.m4a",
- // "fileName": "15099989786 2025-11-11 09-41-57.m4a"
- // }
- const { filePath, fileName } = file;
- // 显示确认对话框
- this.selectedFile = { filePath, fileName };
- this.showConfirmDialog = true;
- },
- // 取消确认
- cancelConfirm() {
- this.showConfirmDialog = false;
- this.selectedFile = { filePath: '', fileName: '' };
- this.form.fileUrl = undefined;
- this.form.fileName = undefined;
- },
- // 确认上传
- async confirmUpload() {
- try {
- // 调用上传接口
- const result = await uni.$u.api.uploadFile(this.selectedFile.filePath);
- if (result && result.data) {
- result.data.remark = this.form.remark;
- result.data.fileName = result.data.name;
- result.data.fileUrl = result.data.url;
- this.form.list = [result.data];
- }
- // 设置表单值
- this.form.fileUrl = this.selectedFile.filePath;
- this.form.fileName = this.selectedFile.fileName;
- // 关闭对话框
- this.showConfirmDialog = false;
- } catch (error) {
- uni.hideLoading();
- console.error('上传失败:', error);
- uni.$u.toast('上传失败,请重试');
- }
- },
- handleNavSaveClick() {
- if (!this.form.clueId) {
- uni.$u.toast("相关线索id为空");
- }
- this.$refs.form.validate().then(async () => {
- await uni.$u.api.saveClueFile(this.form);
- uni.$u.toast("保存成功");
- this.timer = setTimeout(() => {
- uni.$emit('uploadRecordSuccess');
- uni.navigateBack();
- clearTimeout(this.timer);
- }, 1000)
- })
- },
- },
- onLoad(option) {
- this.$store.dispatch("call/getFileList");
- this.form.clueId = option.clueId;
- this.initFormFromStore();
- },
- }
- </script>
- <style lang="scss" scoped>
- .form_wrap {
- background-color: #fff;
- margin: 20rpx 0;
- .form_wrap {
- ::v-deep .u-form-item__body {
- padding: 20rpx 40rpx;
- }
- }
- }
- /* 录音确认对话框样式 */
- .confirm-dialog {
- padding: 40rpx;
- min-width: 500rpx;
- background: #fff;
- border-radius: 20rpx;
- .dialog-title {
- text-align: center;
- font-size: 32rpx;
- font-weight: bold;
- color: #333;
- margin-bottom: 40rpx;
- }
- .dialog-content {
- margin-bottom: 40rpx;
- .file-info {
- margin-bottom: 30rpx;
- .file-name {
- background: #f5f5f5;
- padding: 20rpx;
- border-radius: 10rpx;
- font-size: 28rpx;
- color: #333;
- word-break: break-all;
- text-align: center;
- }
- }
- .play-section {
- .audio-player {
- width: 100%;
- }
- }
- }
- .dialog-buttons {
- display: flex;
- gap: 30rpx;
- ::v-deep .u-button {
- flex: 1;
- }
- }
- }
- </style>
|