index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <div class="page-container column-container">
  3. <!-- 搜索区 -->
  4. <el-form class="list-search-container" :model="queryParams" ref="queryRef" :inline="true">
  5. <el-form-item label="单据号:" prop="formCode">
  6. <el-input v-model="queryParams.formCode" placeholder="请输入单据号" style="width: 144px" clearable
  7. @keyup.enter="handleQuery" />
  8. </el-form-item>
  9. <el-form-item label="表单日期:" prop="formDate">
  10. <el-date-picker v-model="queryParams.formDate" type="date" style="width: 144px" clearable
  11. value-format="YYYY-MM-DD" placeholder="请选择表单日期">
  12. </el-date-picker>
  13. </el-form-item>
  14. <el-form-item label="外协商名称:" prop="supplierName">
  15. <el-input v-model="queryParams.supplierName" placeholder="请输入关键字" style="width: 144px" clearable
  16. @keyup.enter="handleQuery" />
  17. </el-form-item>
  18. <el-form-item label="外协工段:" prop="outsourceDeptName">
  19. <el-input v-model="queryParams.outsourceDeptName" placeholder="请输入关键字" style="width: 144px" clearable
  20. @keyup.enter="handleQuery" />
  21. </el-form-item>
  22. <el-form-item label="送货方式:" prop="deliveryMethod">
  23. <el-select v-model="queryParams.deliveryMethod" style="width: 144px" clearable placeholder="请选择">
  24. <el-option v-for="dict in delivery_method" :key="dict.value" :label="dict.label" :value="dict.value" />
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="带箱方式:" prop="packagingMethod">
  28. <el-select v-model="queryParams.packagingMethod" style="width: 144px" clearable placeholder="请选择">
  29. <el-option v-for="dict in packaging_method" :key="dict.value" :label="dict.label" :value="dict.value" />
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item>
  33. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  34. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  35. </el-form-item>
  36. </el-form>
  37. <!-- 功能按钮区 -->
  38. <div class="list-btns-container">
  39. <el-button type="primary" icon="Plus" @click="handleAdd" v-hasPermi="['business:innerOutsource:add']">
  40. 新增
  41. </el-button>
  42. <el-button type="danger" icon="Delete" :disabled="multiple" @click="handleDelete"
  43. v-hasPermi="['business:innerOutsource:remove']">
  44. 删除
  45. </el-button>
  46. <el-button type="warning" icon="Download" :disabled="ids.length != 1" @click="handleExport"
  47. v-hasPermi="['business:innerOutsource:export']">
  48. 导出
  49. </el-button>
  50. <el-button type="warning" icon="Download" :disabled="ids.length != 1" @click="handlePrint"
  51. v-hasPermi="['business:innerOutsource:export']">
  52. 打印
  53. </el-button>
  54. <el-button type="warning" icon="Printer" :disabled="ids.length === 0" @click="handlePrintCarrierCode"
  55. v-hasPermi="['business:innerOutsource:exportCarrierCode']">
  56. 箱码打印
  57. </el-button>
  58. </div>
  59. <!-- 渲染数据区 -->
  60. <div class="el-table-container">
  61. <div class="el-table-inner-container">
  62. <el-table v-loading="loading" :data="orderList" size="small" border height="100%"
  63. @selection-change="handleSelectionChange">
  64. <el-table-column type="selection" width="48" align="center" />
  65. <el-table-column label="外协单号" align="center" prop="formCode" width="120" />
  66. <el-table-column label="外协日期" align="center" prop="formDate" width="120">
  67. <template #default="scope">
  68. {{ parseTime(scope.row.formDate, "{y}-{m}-{d}") }}
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="外协商名称" align="center" prop="supplierName" width="320" />
  72. <el-table-column label="外协工段" align="center" prop="outsourceDeptName" width="320" />
  73. <el-table-column label="结算方式" align="center" prop="settlementType" width="120">
  74. <template #default="scope">
  75. <dict-tag :options="settlement_type" :value="scope.row.settlementType" />
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="送货方式" align="center" prop="deliveryMethod" width="120">
  79. <template #default="scope">
  80. <dict-tag :options="delivery_method" :value="scope.row.deliveryMethod" />
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="带箱方式" align="center" prop="packagingMethod" width="120">
  84. <template #default="scope">
  85. <dict-tag :options="packaging_method" :value="scope.row.packagingMethod" />
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="备注" align="center" prop="remark" />
  89. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
  90. <template #default="scope">
  91. <el-button v-if="scope.row.isSubmit == 1" link type="warning" icon="Edit" @click="handleUpdate(scope.row)"
  92. v-hasPermi="['business:innerOutsource:edit']">
  93. 编辑
  94. </el-button>
  95. <el-button link type="primary" icon="View" @click="handleView(scope.row)"
  96. v-hasPermi="['business:innerOutsource:query']">
  97. 查看
  98. </el-button>
  99. <el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)"
  100. v-hasPermi="['business:innerOutsource:remove']">
  101. 删除
  102. </el-button>
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. </div>
  107. </div>
  108. <!-- 分页 -->
  109. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
  110. v-model:limit="queryParams.pageSize" @pagination="getList" />
  111. <!-- 表单 -->
  112. <order-form ref="orderRef" :get-list="getList" :delivery-method="delivery_method" :settlement-type="settlement_type"
  113. :packaging-method="packaging_method" />
  114. <!-- 打印箱码 -->
  115. <div id="image-group" style="height: 0px; width: 0px">
  116. <el-image v-for="item in printCarriers" :key="item.id" :src="webHost + item.qcCode" fit="cover"
  117. style="width: 100mm; height: 100mm">
  118. </el-image>
  119. </div>
  120. </div>
  121. </template>
  122. <script setup name="Order">
  123. import {
  124. innerOrderList,
  125. delInnerOrder,
  126. exportOutsource,
  127. printOutsource,
  128. getCarrierInfo
  129. } from "@/api/business/outsourcedOrder";
  130. import orderForm from "./form";
  131. import innerOutsourceStore from "@/store/modules/innerOutsourceOrder";
  132. import printJS from "print-js";
  133. import { nextTick } from "vue";
  134. const { proxy } = getCurrentInstance();
  135. /** 字典数组区 */
  136. const { delivery_method } = proxy.useDict("delivery_method");
  137. const { settlement_type } = proxy.useDict("settlement_type");
  138. const { packaging_method } = proxy.useDict("packaging_method");
  139. const orderList = ref([]);
  140. const loading = ref(true);
  141. const ids = ref([]);
  142. const single = ref(true);
  143. const multiple = ref(true);
  144. const total = ref(0);
  145. const printCarriers = ref([])
  146. const webHost = import.meta.env.VITE_APP_PRODUCTION_API;
  147. /** 查询对象 */
  148. const queryParams = ref({
  149. pageNum: 1,
  150. pageSize: 10,
  151. formCode: null,
  152. formDate: null,
  153. startTime: null,
  154. endTime: null,
  155. supplierName: null,
  156. outsourceDeptName:null,
  157. deliveryMethod: null,
  158. packagingMethod: null,
  159. freightPrice: null,
  160. freightAmount: null,
  161. isFirstProcess:0
  162. });
  163. /*********************** 方法区 ****************************/
  164. /** 查询外协单主
  165. 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子列表 */
  166. function getList() {
  167. console.log(innerOutsourceStore().innerOutsourceQueryParams)
  168. loading.value = true;
  169. if (innerOutsourceStore().innerOutsourceQueryParams != null) {
  170. console.log(innerOutsourceStore().innerOutsourceQueryParams)
  171. queryParams.value = innerOutsourceStore().innerOutsourceQueryParams;
  172. }
  173. innerOrderList(queryParams.value).then((response) => {
  174. orderList.value = response.rows;
  175. total.value = response.total;
  176. loading.value = false;
  177. });
  178. }
  179. /** 搜索按钮操作 */
  180. function handleQuery() {
  181. queryParams.value.pageNum = 1;
  182. const innerOutsourceQueryParams = JSON.parse(JSON.stringify(queryParams.value));
  183. innerOutsourceStore().setInnerOutsourceQueryParams(innerOutsourceQueryParams);
  184. getList();
  185. }
  186. /** 重置按钮操作 */
  187. function resetQuery() {
  188. proxy.resetForm("queryRef");
  189. handleQuery();
  190. }
  191. // 多选框选中数据
  192. function handleSelectionChange(selection) {
  193. ids.value = selection.map((item) => item.id);
  194. single.value = selection.length != 1;
  195. multiple.value = !selection.length;
  196. }
  197. /** 新增按钮操作 */
  198. function handleAdd() {
  199. proxy.$refs.orderRef.open();
  200. }
  201. /** 修改按钮操作 */
  202. function handleUpdate(row) {
  203. const id = row.id || ids.value;
  204. row.flag = true
  205. proxy.$refs.orderRef.open(row);
  206. }
  207. function handleView(row) {
  208. const id = row.id || ids.value;
  209. row.flag = false
  210. proxy.$refs.orderRef.open(row);
  211. }
  212. /** 删除按钮操作 */
  213. function handleDelete(row) {
  214. const _ids = row.id || ids.value;
  215. proxy.$modal
  216. .confirm("是否确认删除选中的数据项?")
  217. .then(function () {
  218. return delInnerOrder(_ids);
  219. })
  220. .then(() => {
  221. getList();
  222. proxy.$modal.msgSuccess("删除成功!");
  223. })
  224. .catch(() => { });
  225. }
  226. /** 导出按钮操作 */
  227. function handleExport() {
  228. exportOutsource({ id: ids.value[0] });
  229. }
  230. /** 导出按钮操作 */
  231. function handlePrint() {
  232. printOutsource({ id: ids.value[0] });
  233. }
  234. /** 打印箱码 */
  235. function handlePrintCarrierCode() {
  236. // 获取箱码地址
  237. if (ids.value.length === 0) {
  238. // 判断是否选中行
  239. proxy.$modal.msgWarning('请选择需要打印箱码的外协单')
  240. return
  241. }
  242. getCarrierInfo(ids.value).then(res => {
  243. if (res.code === 200) {
  244. printCarriers.value = res.data
  245. nextTick(_ => {
  246. if (printCarriers.value.length == 0) {
  247. proxy.$modal.msgWarning('选中外协单无可打印箱码')
  248. return
  249. }
  250. const imageGroup = document.getElementById("image-group");
  251. printJS({
  252. printable: "image-group", // 这里是你要打印内容的DOM元素的id
  253. type: "html",
  254. style: "@page { size: auto; margin: 0mm; }", // 可以添加打印样式
  255. });
  256. })
  257. }
  258. })
  259. }
  260. getList();
  261. </script>