setEntrustDialog.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <el-dialog
  3. title="设置委托"
  4. v-model="formOpen"
  5. width="900px"
  6. append-to-body
  7. draggable
  8. @close="cancel"
  9. >
  10. <el-form ref="dictRef" :model="form" label-width="100">
  11. <el-form-item label="受委托方:">
  12. <el-select placeholder="请选择受委托方" v-model="toTenantId">
  13. <el-option
  14. v-for="(item, index) in factories"
  15. :key="index"
  16. :label="item.accountName"
  17. :value="item.id"
  18. ></el-option>
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item label="委托工单:">
  22. <el-table
  23. :data="list"
  24. size="small"
  25. border
  26. height="100%"
  27. @selection-change="handleSelectionChange"
  28. >
  29. <el-table-column
  30. label="客户名称"
  31. align="center"
  32. min-width="250"
  33. prop="companyName"
  34. />
  35. <el-table-column
  36. label="税号"
  37. align="center"
  38. prop="socialCreditCode"
  39. min-width="180"
  40. />
  41. <el-table-column
  42. label="工单类型"
  43. align="center"
  44. prop="amount"
  45. width="80"
  46. >
  47. <template #default="scope">
  48. {{ scope.row.type === 1 ? "循环工单" : "代办工单" }}
  49. </template>
  50. </el-table-column>
  51. <el-table-column
  52. label="项目"
  53. align="center"
  54. prop="taskTypeName"
  55. width="150"
  56. >
  57. <template #default="scope">
  58. {{ scope.row.taskTypeName }}
  59. {{
  60. scope.row.taskTypeDetailName
  61. ? `-${scope.row.taskTypeDetailName}`
  62. : ""
  63. }}
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="操作" align="center" width="50">
  67. <template #default="scope">
  68. <el-button
  69. type="danger"
  70. size="small"
  71. link
  72. @click="delWorkOrderHandler(scope.$index)"
  73. >删除</el-button
  74. >
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. </el-form-item>
  79. </el-form>
  80. <template #footer>
  81. <div class="dialog-footer">
  82. <el-button
  83. type="primary"
  84. icon="Finished"
  85. size="small"
  86. @click="submitForm"
  87. >确 定</el-button
  88. >
  89. <el-button @click="cancel" icon="close" size="small">取 消</el-button>
  90. </div>
  91. </template>
  92. </el-dialog>
  93. </template>
  94. <script setup>
  95. import {
  96. addEntrust,
  97. getFactories,
  98. } from "@/api/business/entrust/currentWorkOrder";
  99. import { ref } from "vue";
  100. const { proxy } = getCurrentInstance();
  101. const factories = ref([]);
  102. const emit = defineEmits(["choice"]);
  103. const toTenantId = ref(null);
  104. const list = ref([]);
  105. const props = defineProps({
  106. getList: {
  107. type: Function,
  108. default: () => {},
  109. },
  110. });
  111. const { getList } = toRefs(props);
  112. const currentMonth = ref(proxy.moment().format("YYYY-MM-01"));
  113. const formOpen = ref(false);
  114. const form = ref({});
  115. const rules = ref({});
  116. const content = ref("请输入员工姓名");
  117. const ids = ref([]);
  118. function submitForm() {
  119. if (toTenantId.value == null || toTenantId.value == "") {
  120. proxy.$modal.msgError("请选择受委托方!");
  121. return;
  122. }
  123. if (list.value.length == 0) {
  124. proxy.$modal.msgError("请选择要委托的工单!");
  125. return;
  126. }
  127. const entrust = {
  128. workMonth: currentMonth.value,
  129. toTenantId: toTenantId.value,
  130. workOrderIds: list.value.map((l) => l.id),
  131. };
  132. emit("submit", entrust);
  133. // addEntrust(entrust).then((response) => {
  134. // proxy.$modal.msgSuccess("设置完成!");
  135. // formOpen.value = false;
  136. // cancel()
  137. // getList.value()
  138. // });
  139. }
  140. function cancel() {
  141. formOpen.value = false;
  142. reset();
  143. }
  144. function open(options) {
  145. const { optionCurrentMonth, selections } = options;
  146. currentMonth.value = optionCurrentMonth;
  147. list.value = proxy.deepClone(selections);
  148. formOpen.value = true;
  149. }
  150. function delWorkOrderHandler(index) {
  151. proxy.$modal.confirm("是否确认删除选中的数据项?").then(() => {
  152. list.value.splice(index, 1);
  153. });
  154. }
  155. function reset() {
  156. list.value = [];
  157. currentMonth.value = proxy.moment().format("YYYY-MM-01");
  158. toTenantId.value = null;
  159. }
  160. function initFactories() {
  161. getFactories().then((res) => {
  162. factories.value = res.data;
  163. });
  164. }
  165. initFactories();
  166. // 暴露给父组件的方法
  167. defineExpose({
  168. open,
  169. cancel,
  170. });
  171. </script>