index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索表单(不变) -->
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="80px">
  5. <el-form-item label="患者姓名" prop="patientName">
  6. <el-input v-model="queryParams.patientName" placeholder="请输入患者姓名" clearable size="small" @keyup.enter.native="handleQuery" />
  7. </el-form-item>
  8. <el-form-item label="患者电话" prop="patientPhone">
  9. <el-input v-model="queryParams.patientPhone" placeholder="请输入患者电话" clearable size="small" @keyup.enter.native="handleQuery" />
  10. </el-form-item>
  11. <el-form-item label="销售名称" prop="companyUserName">
  12. <el-input v-model="queryParams.companyUserName" placeholder="请输入销售名称" clearable size="small" @keyup.enter.native="handleQuery" />
  13. </el-form-item>
  14. <el-form-item label="订单号" prop="orderCode">
  15. <el-input v-model="queryParams.orderCode" placeholder="请输入订单号" clearable size="small" @keyup.enter.native="handleQuery" />
  16. </el-form-item>
  17. <!-- 创建时间范围查询 -->
  18. <el-form-item label="创建时间">
  19. <el-date-picker
  20. v-model="dateRange"
  21. type="daterange"
  22. range-separator="-"
  23. start-placeholder="开始日期"
  24. end-placeholder="结束日期"
  25. value-format="yyyy-MM-dd"
  26. size="small"
  27. style="width: 240px"
  28. ></el-date-picker>
  29. </el-form-item>
  30. <el-form-item>
  31. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  32. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  33. </el-form-item>
  34. </el-form>
  35. <!-- 操作按钮 -->
  36. <el-row :gutter="10" class="mb8">
  37. <el-col :span="1.5">
  38. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete">删除</el-button>
  39. </el-col>
  40. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" />
  41. </el-row>
  42. <!-- 表格 -->
  43. <el-table v-loading="loading" :data="collectionList" @selection-change="handleSelectionChange">
  44. <el-table-column type="selection" width="55" align="center" />
  45. <el-table-column label="患者姓名" align="center" prop="patientName" />
  46. <el-table-column label="患者电话" align="center" prop="patientPhone" />
  47. <el-table-column label="手写信息采集表" align="center" prop="billImgUrl" width="120">
  48. <template slot-scope="scope">
  49. <el-image
  50. style="width: 50px; height: 50px"
  51. :src="scope.row.billImgUrl"
  52. :preview-src-list="[scope.row.billImgUrl]"
  53. fit="cover">
  54. <div slot="error" class="image-slot">
  55. <i class="el-icon-picture-outline"></i>
  56. </div>
  57. </el-image>
  58. </template>
  59. </el-table-column>
  60. <!-- 新增补充图片列 -->
  61. <el-table-column label="补充图片" align="center" prop="extraImgUrl" width="120">
  62. <template slot-scope="scope">
  63. <div v-if="scope.row.extraImgUrl">
  64. <el-image
  65. style="width: 50px; height: 50px"
  66. :src="getExtraImgList(scope.row.extraImgUrl)[0]"
  67. :preview-src-list="getExtraImgList(scope.row.extraImgUrl)"
  68. fit="cover">
  69. <div slot="error" class="image-slot">
  70. <i class="el-icon-picture-outline"></i>
  71. </div>
  72. </el-image>
  73. <span v-if="getExtraImgList(scope.row.extraImgUrl).length > 1" style="margin-left: 4px; font-size: 12px; color: #999;">
  74. +{{ getExtraImgList(scope.row.extraImgUrl).length - 1 }}
  75. </span>
  76. </div>
  77. <span v-else>-</span>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="订单号" align="center" prop="orderCode" />
  81. <el-table-column label="创建销售" align="center" prop="companyUserName" />
  82. <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  83. <template slot-scope="scope">
  84. <span>{{ parseTime(scope.row.createTime) }}</span>
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  88. <template slot-scope="scope">
  89. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
  90. </template>
  91. </el-table-column>
  92. </el-table>
  93. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  94. </div>
  95. </template>
  96. <script>
  97. import { listCollection, getCollection,delCollection,} from "@/api/company/handwriteCollection";
  98. import ImageUpload from "@/components/ImageUpload";
  99. export default {
  100. name: "HandwriteCollection",
  101. components: { ImageUpload },
  102. data() {
  103. return {
  104. loading: true,
  105. showSearch: true,
  106. total: 0,
  107. collectionList: [],
  108. title: "",
  109. open: false,
  110. ids: [],
  111. single: true,
  112. multiple: true,
  113. originalOrderCode: null,
  114. orderInfoVisible: false,
  115. orderInfo: {},
  116. ocrLoading: false,
  117. ocrMsg: '',
  118. statusOptions: [],
  119. dateRange: [],
  120. queryParams: {
  121. pageNum: 1,
  122. pageSize: 10,
  123. patientName: null,
  124. companyUserName: null,
  125. patientPhone: null,
  126. orderCode: null
  127. },
  128. form: {},
  129. rules: {
  130. patientName: [
  131. { required: true, message: "患者姓名不能为空", trigger: "blur" }
  132. ],
  133. patientPhone: [
  134. { required: true, message: "患者电话不能为空", trigger: "blur" },
  135. { pattern: /^1[3-9]\d{9}$/, message: "请输入正确的手机号码", trigger: "blur" }
  136. ],
  137. orderCode: [
  138. { required: true, message: "订单号不能为空", trigger: "blur" }
  139. ]
  140. }
  141. };
  142. },
  143. created() {
  144. this.getList();
  145. this.getDicts("store_order_status").then(response => {
  146. this.statusOptions = response.data;
  147. }).catch(() => {
  148. this.statusOptions = [];
  149. });
  150. },
  151. methods: {
  152. getList() {
  153. this.loading = true;
  154. // 处理日期范围参数
  155. const params = { ...this.queryParams };
  156. if (this.dateRange && this.dateRange.length === 2) {
  157. params.startDate = this.dateRange[0];
  158. params.endDate = this.dateRange[1];
  159. }
  160. listCollection(this.queryParams).then(response => {
  161. this.collectionList = response.rows;
  162. this.total = response.total;
  163. this.loading = false;
  164. });
  165. },
  166. handleQuery() {
  167. this.queryParams.pageNum = 1;
  168. this.getList();
  169. },
  170. resetQuery() {
  171. this.dateRange = []; // 重置日期范围
  172. this.$refs.queryForm.resetFields();
  173. this.handleQuery();
  174. },
  175. handleAdd() {
  176. this.reset();
  177. this.open = true;
  178. this.title = "添加手写信息采集表";
  179. this.orderInfoVisible = false;
  180. this.ocrMsg = '';
  181. // 新增模式,允许自动识别
  182. this.isNewRecord = true;
  183. },
  184. handleUpdate(row) {
  185. this.reset();
  186. const id = row.id || this.ids[0];
  187. getCollection(id).then(response => {
  188. this.form = response.data;
  189. this.originalOrderCode = this.form.orderCode;
  190. this.open = true;
  191. this.title = "修改手写信息采集表";
  192. this.orderInfoVisible = false;
  193. this.ocrMsg = '';
  194. // 修改模式,不自动识别已有图片
  195. this.isNewRecord = false;
  196. });
  197. },
  198. handleDelete(row) {
  199. const ids = row.id || this.ids.join(",");
  200. this.$confirm('是否确认删除选中的数据项?', '提示', {
  201. confirmButtonText: '确定',
  202. cancelButtonText: '取消',
  203. type: 'warning'
  204. }).then(() => {
  205. return delCollection(ids);
  206. }).then(() => {
  207. this.getList();
  208. this.$message.success("删除成功");
  209. }).catch(() => {});
  210. },
  211. handleSelectionChange(selection) {
  212. this.ids = selection.map(item => item.id);
  213. this.single = selection.length !== 1;
  214. this.multiple = !selection.length;
  215. },
  216. // 将逗号分隔的字符串转为图片URL数组
  217. getExtraImgList(str) {
  218. if (!str) return [];
  219. return str.split(',').filter(url => url.trim() !== '');
  220. },
  221. reset() {
  222. this.form = {
  223. id: null,
  224. patientName: null,
  225. companyUserName: null,
  226. patientPhone: null,
  227. billImgUrl: null,
  228. orderCode: null,
  229. extraImgUrl: ''
  230. };
  231. this.originalOrderCode = null;
  232. this.ocrMsg = '';
  233. this.ocrLoading = false;
  234. if (this.$refs.form) {
  235. this.$refs.form.resetFields();
  236. }
  237. },
  238. cancel() {
  239. this.open = false;
  240. this.reset();
  241. },
  242. parseTime(time) {
  243. if (!time) return '';
  244. const date = new Date(time);
  245. const year = date.getFullYear();
  246. const month = (date.getMonth() + 1).toString().padStart(2, '0');
  247. const day = date.getDate().toString().padStart(2, '0');
  248. const hour = date.getHours().toString().padStart(2, '0');
  249. const minute = date.getMinutes().toString().padStart(2, '0');
  250. const second = date.getSeconds().toString().padStart(2, '0');
  251. return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
  252. }
  253. }
  254. };
  255. </script>
  256. <style scoped>
  257. .order-info-card {
  258. border-radius: 4px;
  259. overflow: hidden;
  260. }
  261. .success-msg {
  262. color: #67C23A;
  263. }
  264. .error-msg {
  265. color: #F56C6C;
  266. }
  267. </style>