plm前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

504 lines
16 KiB

2 years ago
11 months ago
11 months ago
11 months ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
11 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div>
  3. <div style="margin-top: 5px">
  4. <template v-if="isAuth('103001:tab1:save')">
  5. <template v-if="proofingStatus === '草稿' || superAdmin || (approvalUsername && approvalUsername.split(';').includes(sp) && proofingStatus === '审批中')">
  6. <el-button type="primary" @click="clickSaveBtn" v-if="orderNo && !disabled && !readonly">新增</el-button>
  7. </template>
  8. </template>
  9. <template v-if="isAuth('103001:tab1:update')">
  10. <template v-if="proofingStatus === '草稿' || superAdmin || (approvalUsername && approvalUsername.split(';').includes(sp) && proofingStatus === '审批中')">
  11. <el-button type="primary" :loading="loading" v-if="orderNo && !disabled && !readonly" @click="clickSave">{{ attributeDialog?'编辑':'保存' }}</el-button>
  12. </template>
  13. </template>
  14. <template v-if="isAuth('103001:tab1:save')">
  15. <template v-if="proofingStatus === '草稿' || superAdmin || (approvalUsername && approvalUsername.split(';').includes(sp) && proofingStatus === '审批中')">
  16. <el-button type="primary" v-if="attributeDialog && orderNo && !disabled &!readonly" @click="refreshPropertiesModal">刷新属性模板</el-button>
  17. </template>
  18. </template>
  19. </div>
  20. <div class="rq " v-if="attributeDialog">
  21. <el-table
  22. :height="height"
  23. :data="dataList"
  24. border
  25. style="width: 100%;margin-top: 5px">
  26. <el-table-column
  27. v-for="(item,index) in productColumnList" :key="index"
  28. :sortable="item.columnSortable"
  29. :prop="item.columnProp"
  30. :header-align="item.headerAlign"
  31. :show-overflow-tooltip="item.showOverflowTooltip"
  32. :align="item.align"
  33. :fixed="item.fixed===''?false:item.fixed"
  34. :min-width="item.columnWidth"
  35. :label="item.columnLabel">
  36. <template slot-scope="scope">
  37. <div v-if="item.columnProp !== 'textValue' && item.columnProp !== 'numValue'">
  38. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  39. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  40. </div>
  41. <div v-else>
  42. {{scope.row.valueTypeDb==='T'?scope.row.textValue:scope.row.numValue}}
  43. </div>
  44. </template>
  45. </el-table-column>
  46. </el-table>
  47. </div>
  48. <div class="rq " v-else>
  49. <el-table
  50. :height="height"
  51. :data="copyAttributeList"
  52. border
  53. style="width: 100%;margin-top: 5px">
  54. <el-table-column
  55. v-for="(item,index) in productColumnList" :key="index"
  56. :sortable="item.columnSortable"
  57. :prop="item.columnProp"
  58. :header-align="item.headerAlign"
  59. :show-overflow-tooltip="item.showOverflowTooltip"
  60. :align="item.align"
  61. :fixed="item.fixed===''?false:item.fixed"
  62. :min-width="item.columnWidth"
  63. :label="item.columnLabel">
  64. <template slot-scope="scope">
  65. <div v-if="item.columnProp !== 'textValue' && item.columnProp !== 'numValue'">
  66. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  67. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  68. </div>
  69. <div v-else>
  70. <div v-if="scope.row.valueChooseFlag !== 'Y'">
  71. <el-input-number v-model="scope.row.numValue" style="padding: 0;width: 100%" v-if="scope.row.valueType === '数字'" :controls="false"></el-input-number>
  72. <el-input v-model="scope.row.textValue" v-else></el-input>
  73. </div>
  74. <div v-else>
  75. <el-select style="width: 100%;" v-if="scope.row.valueType === '文本'" v-model="scope.row.textValue">
  76. <el-option :value="i.availableValue" :label="i.availableValue" v-for="(i,key) in scope.row.availableValueList" :key="key"></el-option>
  77. </el-select>
  78. <el-select style="width: 100%;" v-else v-model="scope.row.numValue">
  79. <el-option :value="i.availableValue" :label="i.availableValue" v-for="(i,key) in scope.row.availableValueList" :key="key"></el-option>
  80. </el-select>
  81. </div>
  82. </div>
  83. </template>
  84. </el-table-column>
  85. </el-table>
  86. </div>
  87. <el-dialog title="属性项目" v-drag :visible.sync="attributeSaveDialog" append-to-body>
  88. <transfer-table v-if="attributeSaveDialog"
  89. v-model="dataList2"
  90. :data-list="searchDataList"
  91. @add="saveTestPropertiesItem"
  92. @delete="removeTestPropertiesItem"
  93. @search="searchAttributeList"></transfer-table>
  94. <el-footer style="height:40px;margin-top: 20px;text-align:center">
  95. <el-button type="primary" @click="attributeSaveDialog = false">关闭</el-button>
  96. </el-footer>
  97. </el-dialog>
  98. </div>
  99. </template>
  100. <script>
  101. import {propertiesList,refreshPropertiesModal,updatePropertiesList,getPropertiesListByPartAndCodeNo
  102. ,searchPropertiesItemList,saveSubPropertiesValueForAlone,deleteSubPropertiesValueForAlone
  103. } from "@/api/base/properties.js";
  104. import {
  105. removeTestPropertiesItem,
  106. saveTestPropertiesItem, searchTestPropertiesItemList,
  107. updateTestPropertiesList
  108. } from "@/api/test/testProperties.js";
  109. import TransferTable from "../common/transferTable.vue";
  110. export default {
  111. name: "orderAttribute",
  112. components: {TransferTable},
  113. props:{
  114. orderNo: {
  115. type:String,
  116. },
  117. codeNo: {
  118. type:String,
  119. },
  120. approvalUsername: {
  121. type:String,
  122. },
  123. proofingStatus: {
  124. type:String,
  125. },
  126. functionType: {
  127. type:String,
  128. },
  129. disabled: {
  130. type:Boolean,
  131. default:false,
  132. },
  133. readonly: {
  134. type:Boolean,
  135. default:false,
  136. },
  137. superAdmin: {
  138. type: Boolean,
  139. default: false
  140. }
  141. },
  142. data () {
  143. return {
  144. height: 270,
  145. loading: false,
  146. attributeDialog: true,
  147. copyAttributeList: [],
  148. attributeSaveDialog: false,
  149. productColumnList: [
  150. {
  151. userId: this.$store.state.user.name,
  152. functionId: 100002001,
  153. serialNumber: '100002001TablePropertiesItemNo',
  154. tableId: "100002001Table",
  155. tableName: "属性表",
  156. columnProp: 'propertiesItemNo',
  157. headerAlign: "center",
  158. align: "left",
  159. columnLabel: '属性编码',
  160. columnHidden: false,
  161. columnImage: false,
  162. columnSortable: false,
  163. sortLv: 0,
  164. status: true,
  165. fixed: '',
  166. },{
  167. userId: this.$store.state.user.name,
  168. functionId: 100002001,
  169. serialNumber: '100002001TableItemDesc',
  170. tableId: "100002001Table",
  171. tableName: "属性表",
  172. columnProp: 'itemDesc',
  173. headerAlign: "center",
  174. align: "left",
  175. columnLabel: '属性名称',
  176. columnHidden: false,
  177. columnImage: false,
  178. columnSortable: false,
  179. sortLv: 0,
  180. status: true,
  181. fixed: '',
  182. },
  183. {
  184. userId: this.$store.state.user.name,
  185. functionId: 100002001,
  186. serialNumber: '100002001TableValueType',
  187. tableId: "100002001Table",
  188. tableName: "属性表",
  189. columnProp: 'valueType',
  190. headerAlign: "center",
  191. align: "center",
  192. columnLabel: '值类型',
  193. columnHidden: false,
  194. columnImage: false,
  195. columnSortable: false,
  196. sortLv: 0,
  197. status: true,
  198. fixed: '',
  199. columnWidth:80,
  200. },
  201. // {
  202. // userId: this.$store.state.user.name,
  203. // functionId: 100002001,
  204. // serialNumber: '100002001TableMinValue',
  205. // tableId: "100002001Table",
  206. // tableName: "属性表",
  207. // columnProp: 'minValue',
  208. // headerAlign: "center",
  209. // align: "center",
  210. // columnLabel: '最小值',
  211. // columnHidden: false,
  212. // columnImage: false,
  213. // columnSortable: false,
  214. // sortLv: 0,
  215. // status: true,
  216. // fixed: '',
  217. // columnWidth:80,
  218. // },{
  219. // userId: this.$store.state.user.name,
  220. // functionId: 100002001,
  221. // serialNumber: '100002001TableMaxValue',
  222. // tableId: "100002001Table",
  223. // tableName: "属性表",
  224. // columnProp: 'maxValue',
  225. // headerAlign: "center",
  226. // align: "center",
  227. // columnLabel: '最大值',
  228. // columnHidden: false,
  229. // columnImage: false,
  230. // columnSortable: false,
  231. // sortLv: 0,
  232. // status: true,
  233. // fixed: '',
  234. // columnWidth:80,
  235. // },
  236. {
  237. userId: this.$store.state.user.name,
  238. functionId: 100002001,
  239. serialNumber: '100002001TableMaxValue',
  240. tableId: "100002001Table",
  241. tableName: "属性表",
  242. columnProp: 'textValue',
  243. headerAlign: "center",
  244. align: "left",
  245. columnLabel: '属性值',
  246. columnHidden: false,
  247. columnImage: false,
  248. columnSortable: false,
  249. sortLv: 0,
  250. status: true,
  251. fixed: '',
  252. columnWidth:120,
  253. },
  254. // {
  255. // userId: this.$store.state.user.name,
  256. // functionId: 100002001,
  257. // serialNumber: '100002001TableMinValue',
  258. // tableId: "100002001Table",
  259. // tableName: "属性表",
  260. // columnProp: 'numValue',
  261. // headerAlign: "center",
  262. // align: "right",
  263. // columnLabel: '数字值',
  264. // columnHidden: false,
  265. // columnImage: false,
  266. // columnSortable: false,
  267. // sortLv: 0,
  268. // status: true,
  269. // fixed: '',
  270. // columnWidth:120,
  271. // },
  272. // {
  273. // userId: this.$store.state.user.name,
  274. // functionId: 100002001,
  275. // serialNumber: '100002001TableDefaultValue',
  276. // tableId: "100002001Table",
  277. // tableName: "属性表",
  278. // columnProp: 'defaultValue',
  279. // headerAlign: "center",
  280. // align: "right",
  281. // columnLabel: '参照值',
  282. // columnHidden: false,
  283. // columnImage: false,
  284. // columnSortable: false,
  285. // sortLv: 0,
  286. // status: true,
  287. // fixed: '',
  288. // },
  289. ],
  290. searchDataList: [],
  291. dataList: [],
  292. dataList2: [],
  293. sp: this.$store.state.user.name,
  294. }
  295. },
  296. watch: {
  297. orderNo (newValue, oldValue) {
  298. if (newValue) {
  299. this.getProperties()
  300. }
  301. },
  302. },
  303. methods:{
  304. refreshPropertiesModal () {
  305. this.$confirm(`是否刷新至最新模板界面,已填数据会更新到新模板中,若旧属性在新模板中被删除,该条数据会消失。`, '提示', {
  306. confirmButtonText: '确定',
  307. cancelButtonText: '取消',
  308. type: 'warning'
  309. }).then(() => {
  310. let params = {
  311. site: this.$store.state.user.site,
  312. partNo: this.orderNo,
  313. codeNo: this.codeNo,
  314. recordType: this.functionType,
  315. }
  316. refreshPropertiesModal(params).then(({data}) => {
  317. if (data && data.code === 0) {
  318. this.$message.success('操作成功')
  319. this.getProperties()
  320. this.attributeDialog = true
  321. } else {
  322. this.$message.warning(data.msg)
  323. }
  324. this.loading = false
  325. }).catch((error) => {
  326. this.$message.error(error)
  327. this.loading = false
  328. })
  329. })
  330. },
  331. getProperties () {
  332. let params = {
  333. site:this.$store.state.user.site,
  334. partNo: this.orderNo,
  335. codeNo: this.codeNo,
  336. recordType: this.functionType,
  337. }
  338. getPropertiesListByPartAndCodeNo(params).then(({data})=>{
  339. if (data && data.code === 0){
  340. this.dataList = data.rows
  341. this.dataList2 = JSON.parse(JSON.stringify(data.rows))
  342. for (let i = 0; i <this.dataList2.length ; i++) {
  343. this.dataList2[i].itemNo= this.dataList2[i].propertiesItemNo
  344. }
  345. this.searchAttributeList({})
  346. } else {
  347. this.$message.warning(data.msg)
  348. }
  349. }).catch((error)=>{
  350. this.$message.error(error)
  351. })
  352. },
  353. clickSave () {
  354. if (this.dataList.length === 0) {
  355. return false
  356. }
  357. if (!this.attributeDialog) {
  358. this.updateTestPropertiesList()
  359. } else {
  360. this.copyAttributeList = JSON.parse(JSON.stringify(this.dataList))
  361. this.attributeDialog = false
  362. }
  363. },
  364. updateTestPropertiesList () {
  365. this.loading = true
  366. updatePropertiesList(this.copyAttributeList).then(({data})=>{
  367. if (data && data.code === 0){
  368. this.$message.success('操作成功')
  369. this.getProperties()
  370. this.attributeDialog = true
  371. } else {
  372. this.$message.warning(data.msg)
  373. }
  374. this.loading = false
  375. }).catch((error)=>{
  376. this.$message.error(error)
  377. this.loading = false
  378. })
  379. },
  380. clickSaveBtn () {
  381. if (!this.attributeDialog) {
  382. this.$message.warning('请保存更改!')
  383. return
  384. }
  385. //查询 属性模板
  386. this.searchAttributeList({})
  387. this.attributeSaveDialog = true;
  388. },
  389. saveTestPropertiesItem (params) {
  390. let i = 0;
  391. let arr = params.searchTableList.map(item=>{
  392. item.partNo = this.orderNo;
  393. item.site = this.$store.state.user.site;
  394. item.codeNo = this.codeNo;
  395. item.recordType = this.functionType;
  396. return item
  397. })
  398. for (let j = 0; j <arr.length ; j++) {
  399. arr[j].propertiesItemNo= arr[j].itemNo
  400. arr[j].itemNo=999
  401. }
  402. saveSubPropertiesValueForAlone(arr).then(({data})=>{
  403. if (data && data.code === 0){
  404. this.$message.success('操作成功');
  405. this.getProperties(params)
  406. }else {
  407. this.$message.warning(data.msg);
  408. }
  409. }).catch((error)=>{
  410. this.$message.error(error)
  411. })
  412. },
  413. removeTestPropertiesItem(params){
  414. for (let i = 0; i <params.dataTableList.length ; i++) {
  415. params.dataTableList[i].propertiesItemNo= params.dataTableList[i].itemNo
  416. params.dataTableList[i].itemNo=999
  417. }
  418. deleteSubPropertiesValueForAlone(params.dataTableList).then(({data})=>{
  419. if (data && data.code === 0){
  420. this.$message.success('操作成功');
  421. this.getProperties(params)
  422. }else {
  423. this.$message.warning(data.msg);
  424. }
  425. }).catch((error)=>{
  426. this.$message.error(error)
  427. })
  428. },
  429. searchAttributeList(data){
  430. let params= JSON.parse(JSON.stringify(data))
  431. params.site=this.$store.state.user.site;
  432. params.list = this.dataList;
  433. if (!this.attributeSaveDialog){
  434. this.searchDataList = [];
  435. }
  436. let inData={
  437. site:this.$store.state.user.site,
  438. functionType: this.functionType,
  439. list :this.dataList,
  440. codeNo: this.codeNo,
  441. }
  442. searchPropertiesItemList(inData).then(({data}) => {
  443. if (data && data.code === 0){
  444. this.searchDataList = data.rows;
  445. }else {
  446. this.$message.warning(data.msg)
  447. }
  448. }).catch((error)=>{
  449. this.$message.error(error)
  450. })
  451. },
  452. // getPartProperties(){
  453. // let params = {
  454. // site:this.$store.state.user.site,
  455. // partNo: this.orderNo,
  456. // codeNo: this.codeNo,
  457. // functionType: this.functionType,
  458. // }
  459. // getItemListsForPartAndCode(params).then(({data})=>{
  460. // if (data && data.code === 0){
  461. // this.dataList2 = data.rows;
  462. // }else {
  463. // this.$message.warning(data.msg)
  464. // }
  465. // }).catch((error)=>{
  466. // this.$message.error(error)
  467. // })
  468. // },
  469. },
  470. created() {
  471. this.getProperties();
  472. },
  473. }
  474. </script>
  475. <style scoped>
  476. .el-input-number /deep/ .el-input__inner {
  477. text-align: right;
  478. padding-right: 5px !important;
  479. }
  480. /deep/ .el-input .el-input--medium{
  481. line-height: 20px;
  482. }
  483. /deep/ .el-input-number .el-input--medium{
  484. line-height: 20px;
  485. }
  486. </style>