SendSubscribe.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <div style="width: 100%; padding: 0px 15px">
  3. <el-form :model="formData.data" :rules="rules" ref="formDom" label-position="top" :disabled="judgeStatus()">
  4. <!-- <div class="_t">申购信息</div> -->
  5. <div style="margin-left:-15px;margin-bottom:15px">
  6. <TitleInfo :content="'申购信息'"></TitleInfo>
  7. </div>
  8. <el-row :gutter="10">
  9. <el-col :span="6">
  10. <el-form-item label="业务公司" prop="corporationId">
  11. <el-select v-model="formData.data.corporationId" placeholder="请选择" filterable style="width: 100%">
  12. <el-option v-for="item in companyData" :label="item.name" :value="item.id">
  13. </el-option>
  14. </el-select>
  15. </el-form-item>
  16. </el-col>
  17. </el-row>
  18. <el-row :gutter="10">
  19. <el-col :span="6">
  20. <el-form-item label="申购部门" prop="deptName">
  21. <el-input v-model="formData.data.deptName" placeholder="请输入" disabled>
  22. </el-input>
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="6">
  26. <el-form-item label="申购人" prop="subcribeName">
  27. <el-input v-model="formData.data.subcribeName" placeholder="请输入" disabled>
  28. </el-input>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="6">
  32. <el-form-item label="申购时间" prop="subcribeTime">
  33. <el-date-picker v-model="formData.data.subcribeTime" type="datetime" placeholder="请选择" disabled />
  34. </el-form-item>
  35. </el-col>
  36. </el-row>
  37. <el-form-item label="申购说明" prop="subcribeContent">
  38. <el-input v-model="formData.data.subcribeContent" placeholder="请输入" type="textarea">
  39. </el-input>
  40. </el-form-item>
  41. <!-- <div class="_t">申购明细</div> -->
  42. <div style="width:100%">
  43. <div style="width:calc(100% + 80px);margin-left:-45px;background:#F0F2F5;height:15px"></div>
  44. <div :style="{marginTop:true?'15px':''}" style="margin-left:-15px;margin-bottom:15px">
  45. <TitleInfo :content="'申购明细'"></TitleInfo>
  46. </div>
  47. </div>
  48. <el-form-item>
  49. <el-button type="primary" @click="openProduct = true" style="margin: 10px 0">
  50. 添加货品
  51. </el-button>
  52. <el-table :data="formData.data.subscribeDetailList">
  53. <el-table-column prop="goodType" label="货品类型" :formatter="(row) => (row.goodType == 1 ? '产品' : '物料')" />
  54. <el-table-column prop="code" label="货品编码" />
  55. <el-table-column prop="name" label="货品名称" min-width="150" />
  56. <el-table-column prop="spec" label="规格型号" />
  57. <el-table-column prop="unit" label="单位" :formatter="(row) => dictValueLabel(row.unit, productUnit)" />
  58. <el-table-column prop="count" label="申购数量" min-width="150">
  59. <template #default="{ row, $index }">
  60. <el-form-item :prop="'subscribeDetailList.' + $index + '.count'" :rules="rules.count" :inline-message="true">
  61. <el-input-number onmousewheel="return false;" v-model="row.count" :precision="4" :controls="false" :min="1" />
  62. </el-form-item>
  63. </template>
  64. </el-table-column>
  65. <el-table-column prop="remark" label="备注" min-width="150">
  66. <template #default="{ row, $index }">
  67. <el-form-item :prop="'subscribeDetailList.' + $index + '.remark'" :rules="rules.remark" :inline-message="true">
  68. <el-input v-model="row.remark" placeholder="请输入" />
  69. </el-form-item>
  70. </template>
  71. </el-table-column>
  72. <el-table-column prop="zip" label="操作" width="100">
  73. <template #default="{ $index }">
  74. <el-button type="primary" link @click="handleRemove($index)">删除</el-button>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. </el-form-item>
  79. </el-form>
  80. <el-dialog v-if="openProduct" v-model="openProduct" title="选择货品" width="90%" append-to-body>
  81. <!-- <SelectGoods :selectList="acquireSelectList()" @cancel="openProduct = false" @pushGoods="pushGoods"></SelectGoods> -->
  82. <SelectMaterial @selectMaterial="selectMaterial"></SelectMaterial>
  83. </el-dialog>
  84. </div>
  85. </template>
  86. <script setup>
  87. import SelectGoods from "@/components/product/SelectGoods";
  88. import { ElMessage } from "element-plus";
  89. import useUserStore from "@/store/modules/user";
  90. import TitleInfo from "@/components/TitleInfo/index.vue";
  91. import SelectMaterial from "@/components/product/SelectMaterial.vue";
  92. const route = useRoute();
  93. const { proxy } = getCurrentInstance();
  94. // 接收父组件的传值
  95. const props = defineProps({
  96. queryData: String,
  97. });
  98. let formData = reactive({
  99. data: {
  100. subcribeTime: "",
  101. subscribeDetailList: [],
  102. },
  103. });
  104. let rules = ref({
  105. corporationId: [
  106. { required: true, message: "请选择业务公司", trigger: "change" },
  107. ],
  108. deptName: [{ required: true, message: "请输入申购部门", trigger: "blur" }],
  109. subcribeName: [
  110. { required: true, message: "请输入申购人名称", trigger: "blur" },
  111. ],
  112. subcribeTime: [
  113. { required: true, message: "请选择申购时间", trigger: "change" },
  114. ],
  115. // subcribeContent: [
  116. // { required: true, message: "请输入申购事由", trigger: "blur" },
  117. // ],
  118. count: [{ required: true, message: "请输入申购数量", trigger: "blur" }],
  119. // remark: [{ required: true, message: "请输入备注", trigger: "blur" }],
  120. });
  121. let openProduct = ref(false);
  122. const handleRemove = (index) => {
  123. formData.data.subscribeDetailList.splice(index, 1);
  124. return ElMessage({
  125. message: "删除成功!",
  126. type: "success",
  127. });
  128. };
  129. const pushGoods = (goods) => {
  130. if (goods && goods.length > 0) {
  131. let afterFiltering = [];
  132. if (
  133. formData.data.subscribeDetailList &&
  134. formData.data.subscribeDetailList.length > 0
  135. ) {
  136. afterFiltering = goods.filter((item) => {
  137. let data = formData.data.subscribeDetailList.filter(
  138. (itemProduct) => itemProduct.bussinessId === item.id
  139. );
  140. if (data && data.length > 0) {
  141. return false;
  142. }
  143. return true;
  144. });
  145. } else {
  146. afterFiltering = goods;
  147. }
  148. const arr = afterFiltering.map((x) => ({
  149. goodType: x.goodType,
  150. code: x.code,
  151. name: x.name,
  152. spec: x.spec,
  153. unit: x.unit,
  154. productId: x.id,
  155. count: "",
  156. remark: "",
  157. }));
  158. formData.data.subscribeDetailList =
  159. formData.data.subscribeDetailList.concat(arr);
  160. openProduct.value = false;
  161. return ElMessage({
  162. message: "添加成功!",
  163. type: "success",
  164. });
  165. } else {
  166. ElMessage("请选择至少一件物品");
  167. }
  168. };
  169. const formDom = ref(null);
  170. const handleSubmit = async () => {
  171. const vaild = await formDom.value.validate();
  172. if (vaild) {
  173. if (formData.data.subscribeDetailList.length > 0) {
  174. return true;
  175. }
  176. ElMessage({
  177. message: "请添加申购明细!",
  178. type: "info",
  179. });
  180. return false;
  181. }
  182. return false;
  183. };
  184. const userInfo = useUserStore().user;
  185. onMounted(() => {
  186. if (!route.query.processType) {
  187. formData.data.subcribeTime = proxy.parseTime(new Date());
  188. formData.data.deptName = userInfo.dept.deptName;
  189. formData.data.subcribeName = userInfo.nickName;
  190. } else {
  191. }
  192. if (route.query.id) {
  193. proxy
  194. .post("/flowProcess/getStartData", { flowId: route.query.id })
  195. .then((res) => {
  196. formData.data = res;
  197. });
  198. }
  199. });
  200. const judgeStatus = () => {
  201. if (route.query.processType == 20 || route.query.processType == 10) {
  202. return true;
  203. }
  204. if (props.queryData.recordList && props.queryData.recordList.length > 0) {
  205. let data = props.queryData.recordList.filter(
  206. (item) => item.status === 2 && item.nodeType !== 1
  207. );
  208. if (data && data.length > 0) {
  209. return true;
  210. }
  211. }
  212. return false;
  213. };
  214. const productUnit = ref([]);
  215. const companyData = ref([]);
  216. const getDict = () => {
  217. proxy.getDictOne(["unit"]).then((res) => {
  218. productUnit.value = res["unit"].map((x) => ({
  219. label: x.dictValue,
  220. value: x.dictKey,
  221. }));
  222. });
  223. proxy
  224. .post("/corporation/page", { pageNum: 1, pageSize: 9999 })
  225. .then((res) => {
  226. companyData.value = res.rows;
  227. });
  228. };
  229. getDict();
  230. const getFormData = () => {
  231. return proxy.deepClone(formData.data);
  232. };
  233. defineExpose({
  234. getFormData,
  235. handleSubmit,
  236. });
  237. const acquireSelectList = () => {
  238. let data = [];
  239. if (
  240. formData.data.subscribeDetailList &&
  241. formData.data.subscribeDetailList.length > 0
  242. ) {
  243. data = formData.data.subscribeDetailList.map((item) => {
  244. return {
  245. id: item.productId,
  246. name: item.name,
  247. };
  248. });
  249. }
  250. return data;
  251. };
  252. const emit = defineEmits(["auxiliaryChange"]);
  253. let auxiliaryData = ref([
  254. {
  255. label: "最近合同",
  256. data: [
  257. [
  258. {
  259. label: "合同编号",
  260. value: "12312312312456",
  261. fn: () => {
  262. console.log(formData.data);
  263. },
  264. style: {
  265. color: "red",
  266. },
  267. num: 1,
  268. },
  269. {
  270. label: "合同编号",
  271. value: "123456",
  272. fn: () => {
  273. alert("点击事件");
  274. },
  275. },
  276. ],
  277. ],
  278. },
  279. ]);
  280. const auxiliaryChange = (data) => {
  281. emit("auxiliaryChange", data);
  282. };
  283. auxiliaryChange(auxiliaryData);
  284. </script>
  285. <style lang="scss" scoped>
  286. ._t {
  287. margin-bottom: 5px;
  288. font-size: 14px;
  289. }
  290. </style>